public void RemoveClient(UnityClient client) { using (WriteLock.TryEnter(this.readWriteLock, 1000)) { Clients.Remove(client); } }
public void AddClient(UnityClient client) { using (WriteLock.TryEnter(this.readWriteLock, 1000)) { Clients.Add(client); } }
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); }
public ChatInfo(UnityClient client, OperationRequest operationRequest, SendParameters sendParameters) { UnityClient = client; OperationRequest = operationRequest; SendParameters = sendParameters; }