/// <summary> /// 服务器发送信息给 所有客户端 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SendMsg_button_Click(object sender, RoutedEventArgs e) { string serverMsg = InputSendMessage_textBox.Text; if (string.IsNullOrEmpty(serverMsg)) { return; } Socket[] _allSocketArray = new Socket[AllConnectedClient.Count]; AllConnectedClient.CopyTo(_allSocketArray); foreach (Socket oneclient in _allSocketArray) { wudp.Send(oneclient, 0x01, "服务器主动给所有客户端发消息了: " + serverMsg); } }
protected void P2psev2_receiveevent(byte command, string data, Socket soc) { try { WeaveSession _0x01 = Newtonsoft.Json.JsonConvert.DeserializeObject <WeaveSession>(data); if (command == 0xff) { if (_0x01.Request == "token") { token = _0x01.Root; } else if (_0x01.Request == "getnum") { _0x01.Request = "setnum"; _0x01.Token = token; _0x01.Root = getnum().ToString(); p2psev2.Send(soc, 0xff, _0x01.Getjson()); } } } catch { } }
private void Wp2ser_weaveReceiveBitEvent(byte command, byte[] data, System.Net.Sockets.Socket soc) { wp2ser.Send(soc, 0x01, new byte[] { 0x11 }); }