Example #1
0
        /// <summary>
        /// 连接成功,建立接受线程
        /// </summary>
        /// <param name="iar"></param>
        private void _onConnect_Sucess(IAsyncResult iar)
        {
            try
            {
                Socket client = (Socket)iar.AsyncState;
                client.EndConnect(iar);
                receiveThread = new Thread(new ThreadStart(_onReceiveSocket));
                receiveThread.IsBackground = true;
                receiveThread.Start();
                _isConnected = true;

                SGNFDebug.Log("InfoServer connected!");
                SGNFDebug.Log("Requesting ScenarioServer list...");
                byte[] rawData = SocketUtil.ISSerial(new ISSocketModel()
                {
                    Command = (int)SocketUtil.InternalCommand.SSINFO,
                });
                Instance.SendMsgBase(rawData);
            }
            catch (Exception _e)
            {
                Close();
                SGNFDebug.ExceptionCaught(_e);
            }
        }
Example #2
0
 /// <summary>
 /// 发送
 /// </summary>
 /// <param name="_protocalType"></param>
 /// <param name="data"></param>
 public static void SendISMsg(ISSocketModel data)
 {
     if (!IsConnected)
     {
         return;
     }
     byte[] rawData = SocketUtil.ISSerial(data);
     ISSocketManager.Instance.SendMsgBase(rawData);
 }