public void TrySendChatMessage() { var chatRequest = new ChatMessage(UnityClient.Protocol, OperationRequest); if (!chatRequest.IsValid) { UnityClient.SendOperationResponse(chatRequest.GetResponse(ErrorCode.InvalidParameters), SendParameters); return; } string message = chatRequest.Message; message = UnityClient.CharacterName + ": " + message; ChatLobby.Instance.AddMessage(message); var eventData = new EventData((byte)EventCode.ChatMessage); eventData.Parameters = new Dictionary <byte, object>() { { (byte)ParameterCode.ChatMessage, message } }; eventData.SendTo(AccountService.Instance.Clients, SendParameters); }
public void TryAuthorization() { var loginRequest = new Login(UnityClient.Protocol, OperationRequest); UnityClient.CharacterName = loginRequest.CharacterName; if (!loginRequest.IsValid) { UnityClient.SendOperationResponse(loginRequest.GetResponse(ErrorCode.InvalidParameters), SendParameters); return; } if (AccountService.Instance.IsContain(UnityClient.CharacterName)) { UnityClient.SendOperationResponse(loginRequest.GetResponse(ErrorCode.NameIsExist), SendParameters); return; } AccountService.Instance.AddClient(UnityClient); var response = new OperationResponse(OperationRequest.OperationCode); UnityClient.SendOperationResponse(response, SendParameters); }