Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bc626b7

Browse files
authored
修改websocket事件以配合管理系统
1 parent 652736d commit bc626b7

File tree

1 file changed

+12
-7
lines changed
  • GatewayWorker_linux/Applications/YourApp

1 file changed

+12
-7
lines changed

‎GatewayWorker_linux/Applications/YourApp/Events.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public static function onConnect($client_id)
4040
'type' => 'init',
4141
'client_id' => $client_id
4242
];
43-
Gateway::sendToClient(json_decode($data));
43+
44+
Gateway::sendToClient($client_id,json_encode($data));
4445
}
4546

4647
/**
@@ -51,12 +52,16 @@ public static function onConnect($client_id)
5152
public static function onMessage($client_id, $message)
5253
{
5354
// 向所有人发送
54-
$res = json_decode($message, true);
55-
if ($res['type'] === 'ping'){
56-
// 心跳包 前端50秒发送一次
57-
58-
}
59-
// Gateway::sendToAll("$client_id said $message\r\n");
55+
56+
57+
$res = json_decode($message, true);
58+
if ($res['type'] === 'ping'){
59+
// 心跳包 前端50秒发送一次
60+
}
61+
62+
if ($res["msg"] === "gongzuo") {
63+
Gateway::sendToClient($client_id, "gongzuo");
64+
}
6065
}
6166

6267
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /