コード例 #1
0
        public ValueResult <UserModel> LogIn(string name, string email, string clientIpAddress, string serverIpAddress, int port)
        {
            try
            {
                clientIpAddressForTracking = clientIpAddress;
                tcpSocket = new TcpSocketManager(serverIpAddress, port, _mainWindowViewModel);
                SharedStateManager.Instance.initializeSender(tcpSocket);
                var hasExceptionConnection   = tcpSocket.Connect();
                ValueResult <UserModel> user = new ValueResult <UserModel>
                {
                    Value = new UserModel {
                        Name = name, Email = email, UserIpAdress = clientIpAddress
                    }
                };

                tcpSocket.sendInitialMessage(user.Value);

                while (user.Value.UserId == 0)
                {
                    ValueResult <UserModel> tempUser = tcpSocket.ReadUser(user);
                }
                var res = Task.Run(() => tcpSocket.Read());

                return(user);
            }
            catch (Exception e)
            {
                log.Error("Method LogIn is crashed!" + e);
                return(new ValueResult <UserModel>(e));
            }
        }
コード例 #2
0
        public BaseResult SendDisconnectedUser(TcpSocketManager tcpSocketManager, int userId)
        {
            try
            {
                MessageBuffer mb   = new MessageBuffer();
                int           type = 103;
                mb.add(type);
                mb.add(userId);
                Message msg = new Message(mb, Message.MessagesType.COVISE_MESSAGE_VRB_MESSAGE);
                tcpSocketManager.send_msg(msg);
                return(new BaseResult());
            }
            catch (Exception e)
            {
                log.Error("Method SendDisconnectedUser is crashed!" + e);

                return(new BaseResult(e));
            }
        }