Ejemplo n.º 1
0
        /// <summary>
        /// 通知服务端进行套接字的收集
        /// </summary>
        protected void Communication_Server_Client(ClientSocket clientSocket, int port)
        {
            try
            {
                //服务器对该会议开放的端口
                this.intPortNow = port;
                //远程连接
                clientSocket.ConnectRemotePoint(Constant.TreeServiceIP, port);
                //数据接收事件
                clientSocket.TCPDataArrival += clientSocket_TCPDataArrival;

                //发送通知
                ConferenceWebCommon.Common.ConferenceClientAccept conferenceClientAccept = new ConferenceWebCommon.Common.ConferenceClientAccept();
                //会议名称
                conferenceClientAccept.ConferenceName = Constant.ConferenceName;
                //当前参会人uri地址
                conferenceClientAccept.SelfUri = Constant.SelfUri;

                //发送
                clientSocket.SendRemoteData(conferenceClientAccept);
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(this.GetType(), ex);
            }
            finally
            {
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 向远程主机发送消息
 /// </summary>
 /// <param name="packageBase">数据包</param>
 public void SendRemoteData(ConferenceWebCommon.Common.ConferenceClientAccept conferenceClientAccept)
 {
     try
     {
         if (this._clientSocket != null &&
             this._clientSocket.Connected)
         {
             BinaryFormatter formatter = new BinaryFormatter();
             using (MemoryStream ms = new MemoryStream())
             {
                 ms.Position = 0;
                 formatter.Serialize(ms, conferenceClientAccept);//发送到服务器端
                 byte[] data  = ms.ToArray();
                 int    count = this._clientSocket.Send(data, data.Length, SocketFlags.None);
                 Thread.Sleep(10);
             }
         }
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(this.GetType(), ex);
     }
 }