예제 #1
0
 public void Start()
 {
     m_Server      = new XSocket();
     m_Server.Name = "Server";
     m_Server.Listen(m_IP, m_Port, m_MaxConnection, OnAccept);
     m_Server.SocketLog("XSocketServer Start");
 }
예제 #2
0
        private void OnClientReceive(XSocket socket, byte[] buffer, int len)
        {
            var content = System.Text.Encoding.UTF8.GetString(buffer, 0, len);

            m_Server.SocketLog("OnClientReceive:" + socket.Index + "," + content);
            OnClientReceiveCallback?.Invoke(socket.Index, content);
        }
예제 #3
0
 private void OnAccept(IAsyncResult result)
 {
     try
     {
         var server = result.AsyncState as Socket;
         var socket = server.EndAccept(result);
         var conn   = new XSocket();
         conn.Init(socket);
         conn.BeginReceive();
         OnAcceptCallback?.Invoke(conn);
         m_Socket.BeginAccept(OnAccept, m_Socket);
     }
     catch (Exception e)
     {
         SocketLogError("XSocketServer OnAccept ERROR:" + e.Message);
     }
 }
예제 #4
0
 public void Close()
 {
     m_Server.Close();
     m_Server = null;
 }
예제 #5
0
 private void OnClientClose(XSocket socket)
 {
     m_Server.SocketLog("OnClientClose:" + socket.Index);
     OnClientCloseCallback?.Invoke(socket.Index);
 }