Beispiel #1
0
        public Dictionary <string, string> Process(BaseRequestModel model, UserBaseModel user, SocketHelper mySocket, Dictionary <string, string> data)
        {
            var resp = BaseResponseModel.Model <PlayersCountModelResponse>((ushort)MyResponseFlag.PlayersCount);

            resp.Count = mySocket.ParentServer.Clients.Count;

            mySocket.SendMessageToAll(resp);

            return(data);
        }
        public Dictionary <string, string> Process(BaseRequestModel model, UserBaseModel user, SocketHelper mySocket, Dictionary <string, string> data)
        {
            var thisModel = model.ToModel <PingModelRequest>();

            Console.WriteLine($"user float from ping {thisModel.Ping}");
            //Send ping return to client.
            var responseModel = BaseResponseModel.Model <PingModelResponse>((ushort)MyResponseFlag.Ping);

            responseModel.msg  = "abrakadabra";
            responseModel.Ping = thisModel.Ping;

            Console.WriteLine($"Received ping from {user.Name}");
            mySocket.SendMessage(responseModel);

            return(data);
        }
        public Dictionary <string, string> Process(BaseRequestModel model, UserBaseModel user, SocketHelper mySocket, Dictionary <string, string> data)
        {
            var thisModel = model.ToModel <NewConnectionModelRequest>();

            //Update client information.
            user.IpAddress = mySocket.MscClient.Client.RemoteEndPoint.ToString();
            user.Name      = thisModel.Name;

            //Console Message.
            Console.WriteLine(user.IpAddress + $" connected. Name: {thisModel.Name}");
            Console.WriteLine(Convert.ToString(mySocket.ParentServer.Clients.Count) + " clients online.");

            var resp = BaseResponseModel.Model <PlayersCountModelResponse>((ushort)MyResponseFlag.PlayersCount);

            resp.Count = mySocket.ParentServer.Clients.Count;

            mySocket.SendMessageToAll(resp);

            return(data);
        }
Beispiel #4
0
        public Dictionary <string, string> Process(BaseRequestModel model, UserBaseModel user, SocketHelper mySocket, Dictionary <string, string> data)
        {
            var this_model = model.ToModel <LogModelRequest>();

            foreach (var i in this_model.msg)
            {
                Console.WriteLine("msg is:" + i);
            }

            var resp = BaseResponseModel.Model <LogModelResponse>((ushort)MyResponseFlag.LogResponse);

            resp.msg = new List <string>()
            {
                "qwe", "asd"
            };                                             //mySocket.ParentServer.Clients.Count;

            mySocket.SendMessage(resp);

            return(data);
        }