/// <summary>发送消息(部分客户端) deviceIdList:客户端列表</summary> public void SendMsgAll(string msg) { byte[] data = SocketTools.PackageLengthInfo(msg); foreach (SessionTcp session in clientKeyValuePairs.Keys) { session.SendMsg(data); } }
/// <summary>发送消息(所有学生端) sessionTcp:除去某一个学生端</summary> public void SendMsgAll(SessionTcp sessionTcp, string msg) { byte[] bytes = SocketTools.PackageLengthInfo(msg); foreach (SessionTcp session in clientKeyValuePairs.Keys) { if (session != sessionTcp) { session.SendMsg(bytes); } } }
/// <summary>发送消息(部分客户端) deviceIdList:客户端列表</summary> public void SendMsgAll(string msg, List <string> deviceIdList) { byte[] bytes = SocketTools.PackageLengthInfo(msg); foreach (SessionTcp session in clientKeyValuePairs.Keys) { if (deviceIdList.Contains(clientKeyValuePairs[session])) { session.SendMsg(bytes); } } }
/// <summary>发送消息</summary> public void SendMsg(byte[] bytes) { if (client != null && client.session != null) { try { client.session.SendMsg(SocketTools.PackageLengthInfo(bytes)); } catch (Exception e) { Debug.LogError(e); } } }
/// <summary>发送消息</summary> public void SendMsg(SessionTcp session, byte[] bytes) { if (session != null) { try { session.SendMsg(SocketTools.PackageLengthInfo(bytes)); } catch (Exception e) { Debug.LogError(e); } } }
/// <summary>发送消息</summary> public void SendMsg(SessionTcp session, string msg) { if (session != null) { try { byte[] bytes = SocketTools.PackageLengthInfo(msg); session.SendMsg(bytes); } catch (Exception e) { Debug.LogError(e); } } }
public void SendMsg(string msg) { byte[] data = SocketTools.PackageLengthInfo(msg); NetworkStream networkStream = null; try { networkStream = new NetworkStream(socketTcp); if (networkStream.CanWrite) { networkStream.BeginWrite(data, 0, data.Length, SendCallBack, networkStream); } } catch (Exception ex) { SocketTools.LogMsg("SndMsgError:" + ex.Message, LogLevel.Error); } }