Ejemplo n.º 1
0
 /// <summary>发送消息(部分客户端) deviceIdList:客户端列表</summary>
 public void SendMsgAll(string msg)
 {
     byte[] data = SocketTools.PackageLengthInfo(msg);
     foreach (SessionTcp session in clientKeyValuePairs.Keys)
     {
         session.SendMsg(data);
     }
 }
Ejemplo n.º 2
0
 /// <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);
         }
     }
 }
Ejemplo n.º 3
0
 /// <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);
         }
     }
 }
Ejemplo n.º 4
0
 /// <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);
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>发送消息</summary>
 public void SendMsg(SessionTcp session, byte[] bytes)
 {
     if (session != null)
     {
         try
         {
             session.SendMsg(SocketTools.PackageLengthInfo(bytes));
         }
         catch (Exception e)
         {
             Debug.LogError(e);
         }
     }
 }
Ejemplo n.º 6
0
 /// <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);
         }
     }
 }
Ejemplo n.º 7
0
    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);
        }
    }