Exemplo n.º 1
0
 public User GetUser(SocketIOHandler sdw)
 {
     if (clients.ContainsKey(sdw))
     {
         return(clients[sdw]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        void ConnectionCompletedCallback(IAsyncResult ar)
        {
            // Signal the main thread to continue.
            mutex.Set();

            // Get the socket that handles the client request.
            Socket listener = (Socket)ar.AsyncState;
            Socket handler  = listener.EndAccept(ar);

            NetUtil.Log("New client connected from " + (handler.RemoteEndPoint as IPEndPoint).Address);

            SocketIOHandler sdw = new SocketIOHandler(handler);

            clients[sdw] = userForServerCallback?.Invoke(sdw);
            sdw.SetCallback(new ServerMessageCallback(_MessageReceivedCallback));
        }
Exemplo n.º 3
0
        void MessageReceivedCallback(SocketIOHandler socket, JSONObject message)
        {
            NetUtil.Log(socket.IpAddress + ": " + message.ToString());

            if (authenticateUserCallback != null)
            {
                JSONObject response = authenticateUserCallback.Invoke(message.GetString("username"), message.GetString("password"));
                if (useTDES)
                {
                    Send(socket, Convert.ToBase64String(TDES.Encrypt(message.GetString("key"), response.ToString())));
                }
                else
                {
                    Send(socket, response.ToString());
                }
            }
        }
Exemplo n.º 4
0
Arquivo: User.cs Projeto: mtear/pb.net
 public User(SocketIOHandler socketIOHandler)
 {
     this.socketIOHandler = socketIOHandler;
 }
Exemplo n.º 5
0
 User GetUserForServer(SocketIOHandler sdw)
 {
     sdw.Asymkey = rsaKey;
     return(new User(sdw));
 }
Exemplo n.º 6
0
 private void _MessageReceivedCallback(SocketIOHandler user, JSONObject message)
 {
     messageReceivedCallback?.Invoke(user, message);
 }
Exemplo n.º 7
0
 public void Send(SocketIOHandler user, string json)
 {
     user.Send(json);
 }