//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { //Fetch mapped servers ServerMapping serverMapping = Management.MappingConfiguration.MappingConfigurationManager.GetMappingConfiguration().ClientIPMapping; Mapping[] mappedServers = serverMapping.MappingServers; Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetServerMappingResponse getServerMappingResponse = new Alachisoft.NCache.Common.Protobuf.GetServerMappingResponse(); if (mappedServers != null) { for (int i = 0; i < mappedServers.Length; i++) { Common.Protobuf.ServerMapping mappingObject = new Common.Protobuf.ServerMapping(); //Map the server list to protobuf object mappingObject.privateIp = mappedServers[i].PrivateIP; mappingObject.privatePort = mappedServers[i].PrivatePort; mappingObject.publicIp = mappedServers[i].PublicIP; mappingObject.publicPort = mappedServers[i].PublicPort; //Adding to list to be sent as a response getServerMappingResponse.serverMapping.Add(mappingObject); } } else { SocketServer.Logger.NCacheLog.Error("Server Mapping is null"); } response.getServerMappingResponse = getServerMappingResponse; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_SERVER_MAPPING; response.requestId = command.requestID; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); return; } try { //Fetch mapped servers ServerMapping serverMapping = Management.MappingConfiguration.MappingConfigurationManager.GetMappingConfiguration().ClientIPMapping; Mapping[] mappedServers = serverMapping.MappingServers; Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetServerMappingResponse getServerMappingResponse = new Alachisoft.NCache.Common.Protobuf.GetServerMappingResponse(); if (mappedServers != null) { for (int i = 0; i < mappedServers.Length; i++) { Common.Protobuf.ServerMapping mappingObject = new Common.Protobuf.ServerMapping(); //Map the server list to protobuf object mappingObject.privateIp = mappedServers[i].PrivateIP; mappingObject.privatePort = mappedServers[i].PrivatePort; mappingObject.publicIp = mappedServers[i].PublicIP; mappingObject.publicPort = mappedServers[i].PublicPort; //Adding to list to be sent as a response getServerMappingResponse.serverMapping.Add(mappingObject); } } else SocketServer.Logger.NCacheLog.Error("Server Mapping is null"); response.getServerMappingResponse = getServerMappingResponse; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_SERVER_MAPPING; response.requestId = command.requestID; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }