public uint RequestAppServerRegister(CentralServerPeerInfo peerInfo, AckMessageCallback callback) { RequestAppServerRegisterMessage message = new RequestAppServerRegisterMessage(); message.peerInfo = peerInfo; return(ClientSendRequest(MMOMessageTypes.RequestAppServerRegister, message, callback)); }
public uint RequestAppServerRegister(CentralServerPeerInfo peerInfo, AckMessageCallback callback) { RequestAppServerRegisterMessage message = new RequestAppServerRegisterMessage(); message.peerInfo = peerInfo; return(Client.ClientSendAckPacket(DeliveryMethod.ReliableOrdered, MMOMessageTypes.RequestAppServerRegister, message, callback)); }
public void OnCentralServerConnected() { Debug.Log("[" + appServer.PeerType + "] Connected to Central Server"); CentralServerPeerInfo peerInfo = new CentralServerPeerInfo(); peerInfo.peerType = appServer.PeerType; peerInfo.networkAddress = appServer.AppAddress; peerInfo.networkPort = appServer.AppPort; peerInfo.extra = appServer.AppExtra; // Send Request RequestAppServerRegisterMessage message = new RequestAppServerRegisterMessage(); message.peerInfo = peerInfo; ClientSendAckPacket(DeliveryMethod.ReliableOrdered, MMOMessageTypes.RequestAppServerRegister, message, OnAppServerRegistered); }
public void OnCentralServerConnected() { Logging.Log(LogTag, "[" + appServer.PeerType + "] Connected to Central Server"); CentralServerPeerInfo peerInfo = new CentralServerPeerInfo(); peerInfo.peerType = appServer.PeerType; peerInfo.networkAddress = appServer.AppAddress; peerInfo.networkPort = appServer.AppPort; peerInfo.extra = appServer.AppExtra; // Send Request RequestAppServerRegisterMessage message = new RequestAppServerRegisterMessage(); message.peerInfo = peerInfo; SendRequest(MMOMessageTypes.RequestAppServerRegister, message, OnAppServerRegistered); }
protected void HandleRequestAppServerRegister(LiteNetLibMessageHandler messageHandler) { long connectionId = messageHandler.connectionId; RequestAppServerRegisterMessage message = messageHandler.ReadMessage <RequestAppServerRegisterMessage>(); ResponseAppServerRegisterMessage.Error error = ResponseAppServerRegisterMessage.Error.None; if (message.ValidateHash()) { CentralServerPeerInfo peerInfo = message.peerInfo; peerInfo.connectionId = connectionId; switch (message.peerInfo.peerType) { case CentralServerPeerType.MapSpawnServer: mapSpawnServerPeers[connectionId] = peerInfo; if (LogInfo) { Debug.Log("[Central] Register Map Spawn Server: [" + connectionId + "]"); } break; case CentralServerPeerType.MapServer: string sceneName = peerInfo.extra; if (!mapServerPeersBySceneName.ContainsKey(sceneName)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data mapServerPeersBySceneName[sceneName] = peerInfo; mapServerPeers[connectionId] = peerInfo; mapUserIds[connectionId] = new HashSet <string>(); if (LogInfo) { Debug.Log("[Central] Register Map Server: [" + connectionId + "] [" + sceneName + "]"); } } else { error = ResponseAppServerRegisterMessage.Error.MapAlreadyExisted; if (LogInfo) { Debug.Log("[Central] Register Map Server Failed: [" + connectionId + "] [" + sceneName + "] [" + error + "]"); } } break; case CentralServerPeerType.InstanceMapServer: string instanceId = peerInfo.extra; if (!instanceMapServerPeersByInstanceId.ContainsKey(instanceId)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data instanceMapServerPeersByInstanceId[instanceId] = peerInfo; instanceMapServerPeers[connectionId] = peerInfo; mapUserIds[connectionId] = new HashSet <string>(); if (LogInfo) { Debug.Log("[Central] Register Instance Map Server: [" + connectionId + "] [" + instanceId + "]"); } } else { error = ResponseAppServerRegisterMessage.Error.EventAlreadyExisted; if (LogInfo) { Debug.Log("[Central] Register Instance Map Server Failed: [" + connectionId + "] [" + instanceId + "] [" + error + "]"); } } break; case CentralServerPeerType.Chat: chatServerPeers[connectionId] = peerInfo; // Send chat peer info to map servers foreach (CentralServerPeerInfo mapServerPeer in mapServerPeers.Values) { ResponseAppServerAddressMessage responseChatAddressMessage = new ResponseAppServerAddressMessage(); responseChatAddressMessage.responseCode = AckResponseCode.Success; responseChatAddressMessage.error = ResponseAppServerAddressMessage.Error.None; responseChatAddressMessage.peerInfo = peerInfo; ServerSendPacket(mapServerPeer.connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.ResponseAppServerAddress, responseChatAddressMessage); } if (LogInfo) { Debug.Log("[Central] Register Chat Server: [" + connectionId + "]"); } break; } } else { error = ResponseAppServerRegisterMessage.Error.InvalidHash; if (LogInfo) { Debug.Log("[Central] Register Server Failed: [" + connectionId + "] [" + error + "]"); } } ResponseAppServerRegisterMessage responseMessage = new ResponseAppServerRegisterMessage(); responseMessage.ackId = message.ackId; responseMessage.responseCode = error == ResponseAppServerRegisterMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error; responseMessage.error = error; ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.ResponseAppServerRegister, responseMessage); }
protected UniTaskVoid HandleRequestAppServerRegister( RequestHandlerData requestHandler, RequestAppServerRegisterMessage request, RequestProceedResultDelegate <ResponseAppServerRegisterMessage> result) { #if UNITY_STANDALONE && !CLIENT_BUILD long connectionId = requestHandler.ConnectionId; UITextKeys message = UITextKeys.NONE; if (request.ValidateHash()) { ResponseAppServerAddressMessage responseAppServerAddressMessage; CentralServerPeerInfo peerInfo = request.peerInfo; peerInfo.connectionId = connectionId; switch (request.peerInfo.peerType) { case CentralServerPeerType.MapSpawnServer: mapSpawnServerPeers[connectionId] = peerInfo; if (LogInfo) { Logging.Log(LogTag, "Register Map Spawn Server: [" + connectionId + "]"); } break; case CentralServerPeerType.MapServer: string sceneName = peerInfo.extra; if (!mapServerPeersBySceneName.ContainsKey(sceneName)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data mapServerPeersBySceneName[sceneName] = peerInfo; mapServerPeers[connectionId] = peerInfo; mapUserIds[connectionId] = new HashSet <string>(); if (LogInfo) { Logging.Log(LogTag, "Register Map Server: [" + connectionId + "] [" + sceneName + "]"); } } else { message = UITextKeys.UI_ERROR_MAP_EXISTED; if (LogInfo) { Logging.Log(LogTag, "Register Map Server Failed: [" + connectionId + "] [" + sceneName + "] [" + message + "]"); } } break; case CentralServerPeerType.InstanceMapServer: string instanceId = peerInfo.extra; if (!instanceMapServerPeersByInstanceId.ContainsKey(instanceId)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data instanceMapServerPeersByInstanceId[instanceId] = peerInfo; instanceMapServerPeers[connectionId] = peerInfo; mapUserIds[connectionId] = new HashSet <string>(); if (LogInfo) { Logging.Log(LogTag, "Register Instance Map Server: [" + connectionId + "] [" + instanceId + "]"); } } else { message = UITextKeys.UI_ERROR_EVENT_EXISTED; if (LogInfo) { Logging.Log(LogTag, "Register Instance Map Server Failed: [" + connectionId + "] [" + instanceId + "] [" + message + "]"); } } break; case CentralServerPeerType.Chat: chatServerPeers[connectionId] = peerInfo; // Send chat peer info to map servers responseAppServerAddressMessage = new ResponseAppServerAddressMessage() { message = UITextKeys.NONE, peerInfo = peerInfo, }; foreach (CentralServerPeerInfo mapServerPeer in mapServerPeers.Values) { ServerSendPacket(mapServerPeer.connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.AppServerAddress, responseAppServerAddressMessage); } if (LogInfo) { Logging.Log(LogTag, "Register Chat Server: [" + connectionId + "]"); } break; } } else { message = UITextKeys.UI_ERROR_INVALID_SERVER_HASH; if (LogInfo) { Logging.Log(LogTag, "Register Server Failed: [" + connectionId + "] [" + message + "]"); } } // Response result.Invoke( message == UITextKeys.NONE ? AckResponseCode.Success : AckResponseCode.Error, new ResponseAppServerRegisterMessage() { message = message, }); #endif return(default);
private async UniTaskVoid HandleRequestAppServerRegister( RequestHandlerData requestHandler, RequestAppServerRegisterMessage request, RequestProceedResultDelegate <ResponseAppServerRegisterMessage> result) { long connectionId = requestHandler.ConnectionId; UITextKeys message = UITextKeys.NONE; if (request.ValidateHash()) { CentralServerPeerInfo peerInfo = request.peerInfo; peerInfo.connectionId = connectionId; switch (request.peerInfo.peerType) { case CentralServerPeerType.MapSpawnServer: MapSpawnServerPeers[connectionId] = peerInfo; Logging.Log(LogTag, "Register Map Spawn Server: [" + connectionId + "]"); break; case CentralServerPeerType.MapServer: // Extra is map ID if (!MapServerPeersByMapId.ContainsKey(peerInfo.extra)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data MapServerPeersByMapId[peerInfo.extra] = peerInfo; MapServerPeers[connectionId] = peerInfo; Logging.Log(LogTag, "Register Map Server: [" + connectionId + "] [" + peerInfo.extra + "]"); } else { message = UITextKeys.UI_ERROR_MAP_EXISTED; Logging.Log(LogTag, "Register Map Server Failed: [" + connectionId + "] [" + peerInfo.extra + "] [" + message + "]"); } break; case CentralServerPeerType.InstanceMapServer: // Extra is instance ID if (!MapServerPeersByInstanceId.ContainsKey(peerInfo.extra)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data MapServerPeersByInstanceId[peerInfo.extra] = peerInfo; MapServerPeers[connectionId] = peerInfo; Logging.Log(LogTag, "Register Instance Map Server: [" + connectionId + "] [" + peerInfo.extra + "]"); } else { message = UITextKeys.UI_ERROR_EVENT_EXISTED; Logging.Log(LogTag, "Register Instance Map Server Failed: [" + connectionId + "] [" + peerInfo.extra + "] [" + message + "]"); } break; } } else { message = UITextKeys.UI_ERROR_INVALID_SERVER_HASH; Logging.Log(LogTag, "Register Server Failed: [" + connectionId + "] [" + message + "]"); } // Response result.Invoke( message == UITextKeys.NONE ? AckResponseCode.Success : AckResponseCode.Error, new ResponseAppServerRegisterMessage() { message = message, }); await UniTask.Yield(); }
protected UniTaskVoid HandleRequestAppServerRegister( RequestHandlerData requestHandler, RequestAppServerRegisterMessage request, RequestProceedResultDelegate <ResponseAppServerRegisterMessage> result) { long connectionId = requestHandler.ConnectionId; ResponseAppServerRegisterMessage.Error error = ResponseAppServerRegisterMessage.Error.None; if (request.ValidateHash()) { ResponseAppServerAddressMessage responseAppServerAddressMessage; CentralServerPeerInfo peerInfo = request.peerInfo; peerInfo.connectionId = connectionId; switch (request.peerInfo.peerType) { case CentralServerPeerType.MapSpawnServer: mapSpawnServerPeers[connectionId] = peerInfo; if (LogInfo) { Logging.Log(LogTag, "Register Map Spawn Server: [" + connectionId + "]"); } break; case CentralServerPeerType.MapServer: string sceneName = peerInfo.extra; if (!mapServerPeersBySceneName.ContainsKey(sceneName)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data mapServerPeersBySceneName[sceneName] = peerInfo; mapServerPeers[connectionId] = peerInfo; mapUserIds[connectionId] = new HashSet <string>(); if (LogInfo) { Logging.Log(LogTag, "Register Map Server: [" + connectionId + "] [" + sceneName + "]"); } } else { error = ResponseAppServerRegisterMessage.Error.MapAlreadyExisted; if (LogInfo) { Logging.Log(LogTag, "Register Map Server Failed: [" + connectionId + "] [" + sceneName + "] [" + error + "]"); } } break; case CentralServerPeerType.InstanceMapServer: string instanceId = peerInfo.extra; if (!instanceMapServerPeersByInstanceId.ContainsKey(instanceId)) { BroadcastAppServers(connectionId, peerInfo); // Collects server data instanceMapServerPeersByInstanceId[instanceId] = peerInfo; instanceMapServerPeers[connectionId] = peerInfo; mapUserIds[connectionId] = new HashSet <string>(); if (LogInfo) { Logging.Log(LogTag, "Register Instance Map Server: [" + connectionId + "] [" + instanceId + "]"); } } else { error = ResponseAppServerRegisterMessage.Error.EventAlreadyExisted; if (LogInfo) { Logging.Log(LogTag, "Register Instance Map Server Failed: [" + connectionId + "] [" + instanceId + "] [" + error + "]"); } } break; case CentralServerPeerType.Chat: chatServerPeers[connectionId] = peerInfo; // Send chat peer info to map servers responseAppServerAddressMessage = new ResponseAppServerAddressMessage() { error = ResponseAppServerAddressMessage.Error.None, peerInfo = peerInfo, }; foreach (CentralServerPeerInfo mapServerPeer in mapServerPeers.Values) { ServerSendPacket(mapServerPeer.connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.AppServerAddress, responseAppServerAddressMessage); } if (LogInfo) { Logging.Log(LogTag, "Register Chat Server: [" + connectionId + "]"); } break; } } else { error = ResponseAppServerRegisterMessage.Error.InvalidHash; if (LogInfo) { Logging.Log(LogTag, "Register Server Failed: [" + connectionId + "] [" + error + "]"); } } // Response result.Invoke( error == ResponseAppServerRegisterMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error, new ResponseAppServerRegisterMessage() { error = error, }); return(default);