public void OnCreativeInventoryAction(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
 {
     short slot = _pReader.ReadShort();
     short item_id = _pReader.ReadShort();
     short Quanity = _pReader.ReadShort();
     short Damage = _pReader.ReadShort();
 }
Example #2
0
 public MainWindow()
 {
     InitializeComponent();
     SetProgress(50);
     manager = new ClientManager(this);
     manager.Start();
 }
Example #3
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
                if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("RemCmd.Exec", "cmd parsed");

            }
            catch (Exception exc)
            {
                _removeResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }
                return;
            }
            NCache nCache = clientManager.CmdExecuter as NCache;
            try
            {
                CallbackEntry cbEntry = null;

                CompressedValueEntry flagValueEntry = null;

                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                flagValueEntry = nCache.Cache.Remove(cmdInfo.Key, cmdInfo.FlagMap, cbEntry, cmdInfo.LockId, cmdInfo.LockAccessType, operationContext);

                UserBinaryObject ubObject = (flagValueEntry == null) ? null : (UserBinaryObject) flagValueEntry.Value;

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.RemoveResponse removeResponse =
                    new Alachisoft.NCache.Common.Protobuf.RemoveResponse();
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE;
                response.remove = removeResponse;
                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                if (ubObject != null)
                {
                    removeResponse.value.AddRange(ubObject.DataList);
                    removeResponse.flag = flagValueEntry.Flag.Data;
                }
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _removeResult = OperationResult.Failure;

                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(
                    Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
            finally
            {
                if (ServerMonitor.MonitorActivity)
                    ServerMonitor.LogClientActivity("RemCmd.Exec", "cmd executed on cache");
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            ///Command:
            /// GETLOGGINGINFO "requestId"
            ///
            string requestId = string.Empty;

            Alachisoft.NCache.Common.Protobuf.GetLoggingInfoCommand getLoggingInfoCommand = command.getLoggingInfoCommand;
            requestId = getLoggingInfoCommand.requestId.ToString();

            bool errorEnabled = ConnectionManager.GetClientLoggingInfo(LoggingInfo.LoggingType.Error) == LoggingInfo.LogsStatus.Enable;
            bool detailedEnabled = ConnectionManager.GetClientLoggingInfo(LoggingInfo.LoggingType.Detailed) == LoggingInfo.LogsStatus.Enable;

            if (!errorEnabled)
                detailedEnabled = false;

            try
            {
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetLoggingInfoResponse loggingInfoResponse = new Alachisoft.NCache.Common.Protobuf.GetLoggingInfoResponse();
                response.requestId = command.requestID;
                loggingInfoResponse.errorsEnabled = errorEnabled;
                loggingInfoResponse.detailedErrorsEnabled = detailedEnabled;

                response.getLoggingInfoResponse = loggingInfoResponse;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_LOGGING_INFO;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Example #5
0
        public void OnEntityAction(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
        {
            AnimationPacket p = new AnimationPacket(PacketType.EntityAction);
            p.EntityID = _pReader.ReadInt();
            p.Animation = _pReader.ReadByte();
            p.BuildPacket();

            EntityMetadataPacket e_packet = new EntityMetadataPacket(PacketType.EntityMetadata);

            /*
             * /// <summary>
            /// Metadata has a massively quirky packing format,
            /// the details of which are not quite all understood. However,
            /// successful parsing of metadata is possible, according to the following rules.
            /// A metadata field is a byte. The top three bits of the byte,
            /// when masked off and interpreted as a three-bit number from 0 to 7,
            /// indicate the type of the field. The lower five bits are some sort of unknown identifier.
            /// The type of the byte indicates the size and type of a payload which follows the initial byte of the field.
            /// The metadata format consists of at least one field,
            /// followed by either another field or the magic number 0x7F. 0x7F terminates a metadata stream.
            /// Thus, the example metadata stream 0x00 0x01 0x7f is decoded as a field of type 0, id 0,
            /// with a payload of byte 0x00.
            /// </summary>
             * */
        }
Example #6
0
        public void OnAnimation(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
        {
            AnimationPacket p = new AnimationPacket(PacketType.Animation);
            p.EntityID = _pReader.ReadInt();
            p.Animation = _pReader.ReadByte();
            p.BuildPacket();
            int index_me = Chunk.GetIndex((int)_client._player.position.X, (int)_client._player.position.Y, (int)_client._player.position.Z);
            ClientManager[] player = GridServer.player_list;
            for (int i = 0; i < player.Length; i++)
            {
                if (player[i] == null)
                {

                }
                else
                {
                    int index_remote = Chunk.GetIndex((int)player[i]._player.position.X, (int)player[i]._player.position.Y, (int)player[i]._player.position.Z);
                    if (index_remote - 5 < index_me && index_remote + 5 > index_me && _client.id != player[i].id)
                    {
                        player[i].SendPacket(p, player[i].id, ref player[i], false, false);
                    }
                }
            }
            _client.SendPacket(p, _client.id, ref _client, false, false);
        }
Example #7
0
        public PacketHandler OnBlockChange(PacketType p_type, string CustomPacketType, ref PacketReader _pReader, PacketHandler packet, ref ClientManager _client)
        {
            PlayerBlockPlacementPacket _p = (PlayerBlockPlacementPacket)packet;
            BlockChangePacket block_change = new BlockChangePacket(PacketType.BlockChange);
            block_change.Metadata = Utils.GetMetadata(_p.BlockID.s_short, _p.Direction, _client.id);
            //block_change.Metadata = 0x00;
            int X = _p.X;
            byte Y = _p.Y;
            int Z = _p.Z;
            int index = 0;
            int temp = (_p.Direction == 0 ? Y-- :
                (_p.Direction == 1 ? Y++ :
                (_p.Direction == 2 ? Z-- :
                (_p.Direction == 3 ? Z++ :
                (_p.Direction == 4 ? X-- : X++)))));

            if (_p.BlockID.s_short > 255)
            {
                //SendBlockChange(block_change, ref _client, ref _pReader, _p, true);

            }
            else//This is a item ID
            {
                SendBlockChange(block_change, ref _client, ref _pReader, _p, true);
            }
            return block_change;
        }
Example #8
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.ManagementCommand command)
        {
            object result = null;
            try
            {
                if (command.objectName == ManagementUtil.ManagementObjectName.CacheServer)
                {

                    result = CacheProvider.ManagementRpcService.InvokeMethodOnTarget(command.methodName,
                        command.overload,
                        GetTargetMethodParameters(command.arguments));
                }

                Alachisoft.NCache.Common.Protobuf.ManagementResponse response = new Alachisoft.NCache.Common.Protobuf.ManagementResponse();
                response.methodName = command.methodName;
                response.version = command.commandVersion;
                response.requestId = command.requestId;
                response.returnVal = SerializeResponse(result);

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeManagementExceptionResponse(exc, Convert.ToInt32(command.requestId)));
            }
        }
Example #9
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error( "LockCommand", "command: " + command + " Error" + arEx);
                _lockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID));
                }
                return;
            }
            catch (Exception exc)
            {
                _lockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                object lockId = null;
                DateTime lockDate = DateTime.Now;

                bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.VerifyLockResponse verifyLockResponse = new Alachisoft.NCache.Common.Protobuf.VerifyLockResponse();
                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.LOCK_VERIFY;
                response.lockVerify = verifyLockResponse;

                verifyLockResponse.lockId = lockId.ToString();
                verifyLockResponse.success = res;
                verifyLockResponse.lockExpiration = lockDate.Ticks;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _lockResult = OperationResult.Failure;

                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Example #10
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
                if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd parsed");

            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error("UnlockCommand", "command: " + command + " Error" + arEx);
                _unlockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID));
                }
                return;
            }
            catch (Exception exc)
            {
                _unlockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;

                nCache.Cache.Unlock(cmdInfo.Key, cmdInfo.lockId, cmdInfo.isPreemptive, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.UnlockResponse unlockResponse = new Alachisoft.NCache.Common.Protobuf.UnlockResponse();
                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.UNLOCK;
                response.unlockResponse = unlockResponse;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));

            }
            catch (Exception exc)
            {
                _unlockResult = OperationResult.Failure;
                _serializedResponsePackets.Add(clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)));
            }
            finally
            {
                if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd executed on cache");

            }
        }
        //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));
            }
        }
Example #12
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            ClientId = clientManager.ClientID; //Asif Imam

            NCache nCache = clientManager.CmdExecuter as NCache;
            try
            {
                serailizationContext = nCache.CacheId;
                cmdInfo = base.ParseCommand(command, clientManager, serailizationContext);
                if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkInsCmd.Exec", "cmd parsed");
            }
            catch (Exception exc)
            {
                _insertBulkResult = OperationResult.Failure;
                //if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }
                return;
            }

            //TODO
            byte[] dataPackage = null;

            try
            {
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient))
                    operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient);

                Hashtable insertResult = (Hashtable)nCache.Cache.Insert(cmdInfo.Keys, cmdInfo.Values, cmdInfo.CallbackEnteries, cmdInfo.ExpirationHint, cmdInfo.EvictionHint, cmdInfo.QueryInfo, cmdInfo.Flags, operationContext);
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.BulkInsertResponse bulkInsertResponse = new Alachisoft.NCache.Common.Protobuf.BulkInsertResponse();
				response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.intendedRecipient = cmdInfo.IntendedRecipient;
                bulkInsertResponse.keyExceptionPackage = new Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse();

                //TODO : Package Key Value
                Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysExceptions(insertResult, bulkInsertResponse.keyExceptionPackage);

                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.INSERT_BULK;
                response.bulkInsert = bulkInsertResponse;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));

            }
            catch (Exception exc)
            {
                _insertBulkResult = OperationResult.Failure;
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
            if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkInsCmd.Exec", "cmd executed on cache");

        }
Example #13
0
        //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"))
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                int bucketSize = 0;
                NewHashmap hashmap = nCache.Cache.GetOwnerHashMap(out bucketSize);
                byte[] buffer = new byte[0];

                //TODO:Incomplete conversion
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetHashmapResponse getHashmapResponse = new Alachisoft.NCache.Common.Protobuf.GetHashmapResponse();

                response.getHashmap = getHashmapResponse;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_HASHMAP;
                response.requestId = command.requestID;

                if (hashmap != null)
                {
                    getHashmapResponse.viewId = hashmap.LastViewId;
                    getHashmapResponse.bucketSize = bucketSize;

                    foreach (string member in hashmap.Members)
                    {
                        getHashmapResponse.members.Add(member);
                    }
                    foreach (DictionaryEntry entry in hashmap.Map)
                    {
                        Alachisoft.NCache.Common.Protobuf.KeyValuePair keyValue =
                            new Alachisoft.NCache.Common.Protobuf.KeyValuePair();
                        keyValue.key = entry.Key.ToString();
                        keyValue.value = entry.Value.ToString();

                        getHashmapResponse.keyValuePair.Add(keyValue);
                    }
                }
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception 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"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }
                return;
            }

            try
            {
                CallbackInfo cbUpdate = null;
                CallbackInfo cbRemove = null;

                if(cmdInfo.dataFilter != -1) //Default value in protbuf set to -1
                {
                    EventDataFilter datafilter = (EventDataFilter)cmdInfo.dataFilter;

                    cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, datafilter);
                    cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, datafilter, cmdInfo.NotifyOnExpiration);
                }
                else
                {
                    cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None);
                    cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId,EventDataFilter.DataWithMetadata, cmdInfo.NotifyOnExpiration);
                }

                NCache nCache = clientManager.CmdExecuter as NCache;

                nCache.Cache.RegisterKeyNotificationCallback(cmdInfo.Key, cbUpdate, cbRemove
                  , new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse registerKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse();
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF;
                response.registerKeyNotifResponse = registerKeyNotifResponse;
                response.requestId = command.registerKeyNotifCommand.requestId;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));

            }
            catch (Exception exc)
            {
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
    private void Awake() {
        instance = this;
        farnsberg = new Client();
        farnsberg.profilePic = _farnsberg;

        foreach(var cs in characterSprites) {
            var style = cs.style;
            characters[style] = cs.sprites;
        }
    }
 public void Send(OrderItemModel order, int tableId)
 {
     var clientManager = new ClientManager();
     var restaurant = _restaurantManager.Get(order.RestaurantId);
     var client = clientManager.Get().FirstOrDefault(x => x.UserInfo.Login == Context.User.Identity.Name);
     var table = restaurant.Halls.SelectMany(x => x.Tables).FirstOrDefault(x => x.Id == tableId);
     var user = clientManager.Get().FirstOrDefault(x => x.Restaurant.Id == order.RestaurantId);
     order.ClientName = client?.UserInfo.Name;
     Clients.User(user.UserInfo.Login).addOrderToPage(order, table.Number);
 }
 public void OnPlayer(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
 {
     _client._player.onGround = _pReader.ReadBool();// On Ground
     GridServer.player_list[_client.id].WaitToRead = false;
     int i = 0;
     for (; i < base.ModuleAddons.Count; i++)
     {
         base.ModuleAddons.ElementAt(i).Value(pt, ModuleAddons.ElementAt(i).Key, ref _pReader, new PacketHandler(), ref _client);
     }
 }
Example #18
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.ClearCommand clearCommand= command.clearCommand;
            cmdInfo.FlagMap = new BitSet((byte)clearCommand.flag);
            cmdInfo.RequestId = clearCommand.requestId.ToString();

            return cmdInfo;
        }
Example #19
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.CountCommand countCommand = command.countCommand;

            cmdInfo.RequestId = countCommand.requestId.ToString();

            return cmdInfo;
        }
Example #20
0
 void Start()
 {
     gameManager = ClientManager.Get();
     nameInput.onSubmit += delegate () {
         Connect();
     };
     loginButton.onClick.AddListener(() => {
         Connect();
     });
 }
Example #21
0
        public void OnLoginRequest(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
        {
            //[int('protoVersion'),
            //str16('username'),
            //long(/*seed*/),
            //int(/*mode*/),
            //byte(/*world*/),
            //byte(),
            //ubyte(/*height*/),
            //ubyte(/*maxPlayers*/)]
            int version = _pReader.ReadInt();
            string username = _pReader.ReadString();
            string empty_string = _pReader.ReadString();
            _pReader.ReadInt();
            _pReader.ReadInt();
            _pReader.ReadByte();
            _pReader.ReadByte();
            _pReader.ReadByte();
            /*
            Protocol Version	 int	20	 1.2.5's protocol version is 29
            Username	 string	TkTech	 The name of the user attempting to login, max length of 16
            Not used	 string	 (empty string)
            Not used	 int	0
            Not used	 int	0
            Not used	 byte	0
            Not used	 unsigned byte	0
            Not used	 unsigned byte	0
            */

            #region Login Handler Packet
            LoginHandlerPacket p = new LoginHandlerPacket(pt);
            p.EntityID = _client.id;
            p.NotUsed = "";
            p.LevelType = (string)Config.Configuration["LevelType"];
            p.ServerMode = (int)Config.Configuration["ServerMode"];
            p.Dimension = 0;
            p.Difficulty = 1;
            p.WorldHeight = 0;
            p.MaxPlayers = (byte)(int)Config.Configuration["MaxPlayers"];
            p.BuildPacket();
            _client.SendPacket(p, _client.id, ref _client, false, false);
            try
            {
                int i = 0;
                for (; i < base.ModuleAddons.Count; i++)
                {
                    base.ModuleAddons.ElementAt(i).Value(pt, ModuleAddons.ElementAt(i).Key, ref _pReader, (PacketHandler)p, ref _client);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e.Message + " Source:" + e.Source + " Method:" + e.TargetSite + " Data:" + e.Data);
            }
            #endregion Login Handler Packet
        }
        //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"))
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                return;
            }

            Cache cache = null;

            try
            {
                string server = ConnectionManager.ServerIpAddress;
                int port = ConnectionManager.ServerPort;

                Dictionary<string, int> runningServers = new Dictionary<string, int>();

                cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cmdInfo.CacheId);

                if (cache == null) throw new Exception("Cache is not registered");
                if (!cache.IsRunning) throw new Exception("Cache is not running");

                runningServers = cache.GetRunningServers(server, port);
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse getRunningServerResponse = new Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse();

                if (runningServers != null)
                {
                    Dictionary<string, int>.Enumerator ide = runningServers.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        Common.Protobuf.KeyValuePair pair = new Common.Protobuf.KeyValuePair();
                        pair.key = ide.Current.Key;
                        pair.value = ide.Current.Value.ToString();
                        getRunningServerResponse.keyValuePair.Add(pair);
                    }
                }

                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.getRunningServer = getRunningServerResponse;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_RUNNING_SERVERS;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Example #23
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error( "IsLockedCommand", "command: " + command + " Error" + arEx);
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID));
                }
                return;
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                }
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                object lockId = cmdInfo.LockId;
                DateTime lockDate = new DateTime();

                bool res = nCache.Cache.IsLocked(cmdInfo.Key, ref lockId, ref lockDate, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.IsLockedResponse isLockedResponse = new Alachisoft.NCache.Common.Protobuf.IsLockedResponse();
                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.ISLOCKED;
                response.isLockedResponse = isLockedResponse;

                isLockedResponse.isLocked = res;
                isLockedResponse.lockId = lockId.ToString();
                isLockedResponse.lockTime = lockDate.Ticks;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.GetRunningServersCommand getRunningServerCommand = command.getRunningServersCommand;

            cmdInfo.CacheId = getRunningServerCommand.cacheId;
            cmdInfo.IsDotNetClient = getRunningServerCommand.isDotnetClient;
            cmdInfo.RequestId = getRunningServerCommand.requestId.ToString();
            return cmdInfo;
        }
 //PROTOBUF
 private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
 {
     CommandInfo cmdInfo = new CommandInfo();
     //HACK:notifMask
     Alachisoft.NCache.Common.Protobuf.RegisterNotifCommand registerNotifCommand = command.registerNotifCommand;
     cmdInfo.RegNotifs = registerNotifCommand.notifMask;
     cmdInfo.RequestId = registerNotifCommand.requestId.ToString();
     cmdInfo.datafilter = registerNotifCommand.datafilter;
     cmdInfo.sequence = registerNotifCommand.sequence;
     return cmdInfo;
 }
Example #26
0
 public void ServerTest()
 {
     ClientManager clientManager = new ClientManager();
     GameManager gameManager = new GameManager();
     Listener listener = new Listener(new TcpListener(endPoint));
     server = new Server(listener, clientManager, gameManager);
     server.Start();
     tcpClientA.Connect(endPoint);
     tcpClientB.Connect(endPoint);
     Assert.AreEqual(true, tcpClientA.Connected);
 }
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.UnRegisterKeyNotifCommand unRegisterKeyNotifCommand = command.unRegisterKeyNotifCommand;
            cmdInfo.Key = unRegisterKeyNotifCommand.key;
            cmdInfo.RemoveCallbackId = (short)unRegisterKeyNotifCommand.removeCallbackId;
            cmdInfo.RequestId = unRegisterKeyNotifCommand.requestId.ToString();
            cmdInfo.UpdateCallbackId = (short)unRegisterKeyNotifCommand.updateCallbackId;

            return cmdInfo;
        }
Example #28
0
 private void Prueba_Load(object sender, EventArgs e)
 {
     BindingSource bs = new BindingSource();
     ClientManager clientManager = new ClientManager();
     List<Client> query = clientManager.GetActiveClients().ToList();
     bs.DataSource = query.ToList();
     dataGridView1.DataSource = bs;
     foreach (var item in query)
     {
         listBox1.Items.Add(item);
     }
 }
Example #29
0
        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"))
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));

                return;
            }

            int count = 0;
            string keyPackage = null;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext);

                if (!clientManager.EnumerationPointers.ContainsKey(cmdInfo.Pointer.Id))
                {
                    clientManager.EnumerationPointers.Add(cmdInfo.Pointer.Id, cmdInfo.Pointer);
                }
                else
                {
                    clientManager.EnumerationPointers[cmdInfo.Pointer.Id] = cmdInfo.Pointer;
                }

                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse();
                response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                response.intendedRecipient = cmdInfo.OperationContext.GetValueByField(OperationContextFieldName.IntendedRecipient).ToString();
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_NEXT_CHUNK;
                response.getNextChunkResponse = getNextChunkResponse;

                if (nextChunk.Data != null)
                    getNextChunkResponse.keys.AddRange(nextChunk.Data);

                getNextChunkResponse.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(nextChunk.Pointer);

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
Example #30
0
        /// <summary>
        ///     Initializes a new instance of the Server class.
        /// </summary>
        /// <param name="name">Server name.</param>
        /// <param name="speed">Server speed.</param>
        /// <param name="address">Server url address.</param>
        public Server(string name, int speed, string address)
        {
            Name = name;
            Speed = speed;
            Address = address;
            ClientManager = new ClientManager(this);
            AccountManager = new AccountManager();
            PlayerManager = new PlayerManager(this);
            VillageManager = new VillageManager(this);
            AllyManager = new AllyManager(this);

            ClientManager.NewClient += OnNewClientCreated;
        }
Example #31
0
 public NewChatManager(ClientManager clientManager)
 {
     _clientManager = clientManager;
     _viewModel     = new ChatboxModel();
 }
Example #32
0
 public ClientRoleEditViewComponent(ClientManager clientManager, RoleManager roleManager)
 {
     _clientManager = clientManager;
     _roleManager   = roleManager;
 }
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.GetServerMappingCommand getServerMappingCommand = command.getServerMappingCommand;
            cmdInfo.RequestId = getServerMappingCommand.requestId.ToString();

            return(cmdInfo);
        }
Example #34
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.LockCommand lockCommand = command.lockCommand;
            //HACK : Flag map missing, becuase it never used
            cmdInfo.Key         = lockCommand.key;
            cmdInfo.LockTimeout = new TimeSpan(lockCommand.lockTimeout);
            cmdInfo.RequestId   = lockCommand.requestId.ToString();
            cmdInfo.ThreadId    = lockCommand.threadId;

            return(cmdInfo);
        }
Example #35
0
 public InitClientEvent(ClientManager clients)
 {
     Clients = clients;
 }
Example #36
0
        //PROTOBUF

        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            byte[] data = null;

            NCache    nCache = clientManager.CmdExecuter as NCache;
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload             = command.MethodOverload;
                serializationContext = nCache.CacheId;
                cmdInfo = ParseCommand(nCache.Cache, command);
            }
            catch (System.Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            data = new byte[1];
            try
            {
                var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress);
                //PROTOBUF:RESPONSE
                bool result = nCache.Cache.AddExpirationHint(cmdInfo.Key, cmdInfo.ExpHint, operationContext);
                //PROTOBUF:RESPONSE
                stopWatch.Stop();

                AddAttributeResponse addResponse = new AddAttributeResponse();
                addResponse.success = result;
                if (clientManager.ClientVersion >= 5000)
                {
                    ResponseHelper.SetResponse(addResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(addResponse, Response.Type.ADD_ATTRIBUTE));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Response response = new Response();
                    response.addAttributeResponse = addResponse;
                    ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.ADD_ATTRIBUTE);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (System.Exception exc)
            {
                //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                //PROTOBUF:RESPONSEexception = exc.ToString();
                exception = exc.ToString();
                //_resultPacket = Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID);
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                stopWatch.Stop();
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log            = new APILogItemBuilder(MethodsName.SetAttributes.ToLower());
                        Hashtable         expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpHint, null);
                        log.GenerateAddAttributeAPILogItem(cmdInfo.Key, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString());
                    }
                }
                catch { }
            }
        }
Example #37
0
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.GetNextChunkCommand getNextChunkCommand = command.getNextChunkCommand;
            cmdInfo.RequestId = getNextChunkCommand.requestId.ToString();
            cmdInfo.Pointer   = EnumerationPointerConversionUtil.GetFromProtobufEnumerationPointer(getNextChunkCommand.enumerationPointer);

            string intendedRecepient = command.intendedRecipient;
            long   lastViewId        = command.clientLastViewId;

            cmdInfo.OperationContext = new OperationContext();
            cmdInfo.OperationContext.Add(OperationContextFieldName.IntendedRecipient, intendedRecepient);
            cmdInfo.OperationContext.Add(OperationContextFieldName.ClientLastViewId, lastViewId);

            return(cmdInfo);
        }
Example #38
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;

                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);

                nCache.Cache.Remove(cmdInfo.Group, cmdInfo.SubGroup, operationContext);
                stopWatch.Stop();

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.Response            response            = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.RemoveGroupResponse removeGroupResponse = new Alachisoft.NCache.Common.Protobuf.RemoveGroupResponse();
                response.requestId           = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID           = command.commandID;
                response.responseType        = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE_GROUP;
                response.removeGroupResponse = removeGroupResponse;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                exception = exc.ToString();

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.RemoveGroupData.ToLower());
                        log.GeneratRemoveGroupDataAPILogItem(cmdInfo.Group, cmdInfo.SubGroup, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
 public LoginInfoPanelViewComponent(ClientManager clientManager)
 {
     this.ClientManager = clientManager;
 }
Example #40
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.BulkRemoveCommand bulkRemoveCommand = command.bulkRemoveCommand;
            cmdInfo.Keys             = new ArrayList(bulkRemoveCommand.keys).ToArray();
            cmdInfo.FlagMap          = new BitSet((byte)bulkRemoveCommand.flag);
            cmdInfo.RequestId        = bulkRemoveCommand.requestId.ToString();
            cmdInfo.ClientLastViewId = command.clientLastViewId;
            cmdInfo.CommandVersion   = command.commandVersion;
            return(cmdInfo);
        }
Example #41
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.LockVerifyCommand lockVerifyCommand = command.lockVerifyCommand;

            cmdInfo.Key       = lockVerifyCommand.key;
            cmdInfo.RequestId = lockVerifyCommand.requestId.ToString();


            return(cmdInfo);
        }
Example #42
0
 void Awake()
 {
     Instance = this;
 }
Example #43
0
 public TestController(ClientManager clientManager)
 {
     ClientManager = clientManager;
 }
Example #44
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;
            Stopwatch   stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("LockCmd.Exec", "cmd parsed");
                }
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("LockCommand", "command: " + command + " Error" + arEx);
                }
                _lockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //   _resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(arEx, base.immatureId), base.ParsingExceptionMessage(arEx));
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }
            catch (Exception exc)
            {
                _lockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                    //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                }
                return;
            }
            object lockId = null;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;

                DateTime lockDate = DateTime.Now;

                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID);
                operationContext.Add(OperationContextFieldName.ClientThreadId, cmdInfo.ThreadId);
                operationContext.Add(OperationContextFieldName.IsRetryOperation, command.isRetryCommand);

                bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, operationContext);
                stopWatch.Stop();
                string lockIdString = lockId == null ? "" : lockId.ToString();

                //PROTOBUF:RESPONSE
                //Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.LockResponse lockResponse = new Alachisoft.NCache.Common.Protobuf.LockResponse();

                lockResponse.lockId   = lockIdString;
                lockResponse.locked   = res;
                lockResponse.lockTime = lockDate.Ticks;
                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(lockResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(lockResponse, Common.Protobuf.Response.Type.LOCK));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.lockResponse = lockResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.LOCK);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                _lockResult = OperationResult.Failure;
                //PROTOBUF:RESPONSE
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Lock.ToLower());
                        log.GenerateLockAPILogItem(cmdInfo.Key, cmdInfo.LockTimeout, lockId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("LockCmd.Exec", "cmd executed on cache");
                }
            }
        }
Example #45
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload  = 0;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            Keys = new List <string>();
            string key    = null;
            NCache nCache = clientManager.CmdExecuter as NCache;

            try
            {
                overload = command.MethodOverload;

                switch (command.type)
                {
                case Common.Protobuf.Command.Type.CONTAINS:
                    Alachisoft.NCache.Common.Protobuf.ContainsCommand containsCommand = command.containsCommand;

                    Keys.Add(containsCommand.key);
                    key       = containsCommand.key;
                    RequestId = containsCommand.requestId.ToString();
                    break;

                case Common.Protobuf.Command.Type.CONTAINS_BULK:
                    Alachisoft.NCache.Common.Protobuf.ContainsBulkCommand containsBulkCommand = command.containsBulkCommand;

                    Keys      = containsBulkCommand.keys;
                    RequestId = containsBulkCommand.requestId.ToString();
                    break;

                default:
                    throw new Exception("Invalid Command Received in ContainsCommand");
                }

                Hashtable exists = nCache.Cache.Contains(Keys, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));

                stopWatch.Stop();

                if (clientManager.ClientVersion >= 5000)
                {
                    Alachisoft.NCache.Common.Protobuf.ContainBulkResponse containsBulkResponse = new Alachisoft.NCache.Common.Protobuf.ContainBulkResponse();

                    containsBulkResponse.exists = CompactBinaryFormatter.ToByteBuffer(exists, null);

                    ResponseHelper.SetResponse(containsBulkResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(containsBulkResponse, Common.Protobuf.Response.Type.CONTAINS_BULK));
                }
                else
                {
                    Alachisoft.NCache.Common.Protobuf.Response        response        = new Alachisoft.NCache.Common.Protobuf.Response();
                    Alachisoft.NCache.Common.Protobuf.ContainResponse containResponse = new Alachisoft.NCache.Common.Protobuf.ContainResponse();

                    IDictionary <string, bool> keysPresent = ExtractKeyStatus(exists, Keys);
                    containResponse.exists = keysPresent[key];
                    response.contain       = containResponse;
                    ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.CONTAINS);

                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }

            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }

            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Contains.ToLower());
                        log.GenerateContainsCommandAPILogItem(key, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
            if (ServerMonitor.MonitorActivity)
            {
                ServerMonitor.LogClientActivity("ContCmd.Exec", "cmd executed on cache");
            }
        }
Example #46
0
 public static void CheckBidder(Client client)
 {
     //if (client.Player.CharID == AuctionMaster) {
     Messenger.BattleMsg(client, "The highest bidder is " + ClientManager.FindClient(highestBidder).Player.Name + ", with a bid of " + highestBid.ToString() + " Poké! (" + SetItem + ")", Text.BrightGreen);
     //}
 }
Example #47
0
        public override bool ProcessCommand(Client client, Command command, string joinedArgs)
        {
            if (!Data.Started)
            {
                return(false);
            }

            var userData = Data.ExtendPlayer(client);

            switch (command[0])
            {
            case "/wrole":
                Messenger.PlayerMsg(client, $"You are a {userData.Role}!", Text.BrightGreen);
                return(true);

            case "/walive":
                Messenger.PlayerMsg(client, "The following players are alive:", Text.BrightGreen);
                foreach (var eventClient in GetRegisteredClients().Where(x => !Data.ExtendPlayer(x).IsDead))
                {
                    if (!Ranks.IsAllowed(client, Enums.Rank.Scripter))
                    {
                        Messenger.PlayerMsg(client, eventClient.Player.DisplayName, Text.BrightGreen);
                    }
                    else
                    {
                        var eventPlayerData = Data.ExtendPlayer(eventClient);

                        Messenger.PlayerMsg(client, $"{eventClient.Player.DisplayName} - {eventPlayerData.Role}", Text.BrightGreen);
                    }
                }
                return(true);

            case "/wchoose":
                var chosenClient = ClientManager.FindClient(joinedArgs);
                if (chosenClient == null)
                {
                    Messenger.PlayerMsg(client, "Player is offline.", Text.BrightRed);
                    return(true);
                }

                if (Data.ExtendPlayer(chosenClient).IsDead)
                {
                    Messenger.PlayerMsg(client, "Player is already dead!", Text.BrightRed);
                    return(true);
                }
                if (userData.IsDead)
                {
                    Messenger.PlayerMsg(client, "You can't make any choices while dead!", Text.BrightRed);
                    return(true);
                }

                switch (Data.GameState)
                {
                case GameState.WerewolfSelecting:
                {
                    if (userData.Role == UserRole.Werewolf)
                    {
                        if (Data.ExtendPlayer(chosenClient).Role == UserRole.Werewolf)
                        {
                            Messenger.PlayerMsg(client, "You can't choose another werewolf!", Text.BrightRed);
                            return(true);
                        }

                        userData.SelectedCharId = chosenClient.Player.CharID;
                        RoleAlertMessage(UserRole.Werewolf, $"{client.Player.DisplayName} chose {chosenClient.Player.DisplayName}!");
                    }

                    if (CanTransition())
                    {
                        TransitionNext(GameState.DoctorSelecting);
                    }
                }
                break;

                case GameState.DoctorSelecting:
                {
                    if (userData.Role == UserRole.Doctor)
                    {
                        userData.SelectedCharId = chosenClient.Player.CharID;
                    }

                    if (CanTransition())
                    {
                        TransitionNext(GameState.SeerSelecting);
                    }
                }
                break;

                case GameState.SeerSelecting:
                {
                    if (userData.Role == UserRole.Seer)
                    {
                        userData.SelectedCharId = chosenClient.Player.CharID;

                        if (Data.ExtendPlayer(chosenClient).Role == UserRole.Werewolf)
                        {
                            Messenger.PlayerMsg(client, $"{chosenClient.Player.DisplayName} is a werewolf!", Text.BrightGreen);
                        }
                        else
                        {
                            Messenger.PlayerMsg(client, $"{chosenClient.Player.DisplayName} is not a werewolf!", Text.BrightRed);
                        }
                    }

                    if (CanTransition())
                    {
                        Transition(GameState.VillagersSelecting);
                    }
                }
                break;

                case GameState.VillagersSelecting:
                {
                    userData.SelectedCharId = chosenClient.Player.CharID;

                    foreach (var eventClient in GetRegisteredClients())
                    {
                        Messenger.PlayerMsg(eventClient, $"[Werewolf] {client.Player.DisplayName} chose {chosenClient.Player.DisplayName}!", Text.White);
                    }

                    if (CanTransition())
                    {
                        var majoritySelection = GetMajorityPlayerSelection();

                        ExecuteTurn(majoritySelection);
                    }
                }
                break;
                }
                return(true);

            case "/w":
            {
                if (userData.Role == UserRole.Werewolf)
                {
                    WerewolfMessage(client, joinedArgs);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            default:
                return(false);
            }
        }
Example #48
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.GetKeysByTagCommand getTagCommand = command.getKeysByTagCommand;

            cmdInfo.ComparisonType   = (TagComparisonType)getTagCommand.tagComparisonType;
            cmdInfo.RequestId        = getTagCommand.requestId.ToString();
            cmdInfo.Tags             = getTagCommand.tags.ToArray();
            cmdInfo.ClientLastViewId = command.clientLastViewId;

            return(cmdInfo);
        }
Example #49
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();

            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }

                return;
            }

            int    count      = 0;
            string keyPackage = null;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext);
                stopWatch.Stop();
                if (!clientManager.EnumerationPointers.ContainsKey(cmdInfo.Pointer.Id))
                {
                    clientManager.EnumerationPointers.Add(cmdInfo.Pointer.Id, cmdInfo.Pointer);
                }
                else
                {
                    clientManager.EnumerationPointers[cmdInfo.Pointer.Id] = cmdInfo.Pointer;
                }

                if (clientManager.ClientVersion >= 5000)
                {
                    Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse();
                    getNextChunkResponse.requestId = Convert.ToInt64(cmdInfo.RequestId);

                    getNextChunkResponse.commandID         = command.commandID;
                    getNextChunkResponse.intendedRecipient = cmdInfo.OperationContext.GetValueByField(OperationContextFieldName.IntendedRecipient).ToString();

                    if (nextChunk.Data != null)
                    {
                        getNextChunkResponse.keys.AddRange(nextChunk.Data);
                    }

                    getNextChunkResponse.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(nextChunk.Pointer);

                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getNextChunkResponse, Common.Protobuf.Response.Type.GET_NEXT_CHUNK));
                }
                else
                {
                    Alachisoft.NCache.Common.Protobuf.Response             response             = new Alachisoft.NCache.Common.Protobuf.Response();
                    Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetNextChunkResponse();
                    response.requestId = Convert.ToInt64(cmdInfo.RequestId);

                    response.commandID            = command.commandID;
                    response.intendedRecipient    = cmdInfo.OperationContext.GetValueByField(OperationContextFieldName.IntendedRecipient).ToString();
                    response.responseType         = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_NEXT_CHUNK;
                    response.getNextChunkResponse = getNextChunkResponse;

                    if (nextChunk.Data != null)
                    {
                        getNextChunkResponse.keys.AddRange(nextChunk.Data);
                    }

                    getNextChunkResponse.enumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufEnumerationPointer(nextChunk.Pointer);

                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetNextChunk.ToLower());
                        log.GenerateGetEnumeratorAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());

                        // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                    }
                }
                catch
                {
                }
            }
        }
Example #50
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            int responseResult = 0;

            byte[] data = null;

            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("GetCommand", "command: " + command + " Error" + arEx);
                }
                _getResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID, command.commandID));
                }
                return;
            }
            catch (Exception exc)
            {
                _getResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            try
            {
                NCache           nCache           = clientManager.CmdExecuter as NCache;
                ICollection      result           = null;
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout);
                operationContext.CancellationToken = CancellationToken;

                result = nCache.Cache.GetKeysByTag(cmdInfo.Tags, cmdInfo.ComparisonType, operationContext);
                stopWatch.Stop();
                responseResult = result.Count;
                Alachisoft.NCache.Common.Protobuf.Response             response       = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetKeysByTagResponse getTagResponse = new Alachisoft.NCache.Common.Protobuf.GetKeysByTagResponse();
                response.requestId    = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID    = command.commandID;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_KEYS_TAG;

                response.getKeysByTagResponse = getTagResponse;

                if (result != null)
                {
                    Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeys(result.GetEnumerator(), getTagResponse.keys);
                }
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (OperationCanceledException ex)
            {
                exception = ex.ToString();
                Dispose();
            }
            catch (Exception exc)
            {
                exception  = exc.ToString();
                _getResult = OperationResult.Failure;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        if (cmdInfo.ComparisonType == TagComparisonType.ALL_MATCHING_TAGS)
                        {
                            APILogItemBuilder log  = new APILogItemBuilder(MethodsName.GetKeysByAllTags.ToLower());
                            Hashtable         tags = new Hashtable();
                            foreach (string tag in cmdInfo.Tags)
                            {
                                tags.Add(tag, tag);
                            }
                            log.GenerateGetByAllTagsAPILogItem(tags, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), responseResult);
                        }
                        else if (cmdInfo.ComparisonType == TagComparisonType.BY_TAG)
                        {
                            APILogItemBuilder log  = new APILogItemBuilder(MethodsName.GetKeysByTag.ToLower());
                            Hashtable         tags = new Hashtable();
                            foreach (string tag in cmdInfo.Tags)
                            {
                                tags.Add(tag, tag);
                            }
                            log.GenerateGetByTagAPILogItem(tags, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), responseResult);
                        }
                        else if (cmdInfo.ComparisonType == TagComparisonType.ANY_MATCHING_TAG)
                        {
                            APILogItemBuilder log  = new APILogItemBuilder(MethodsName.GetKeysByAnyTag.ToLower());
                            Hashtable         tags = new Hashtable();
                            foreach (string tag in cmdInfo.Tags)
                            {
                                tags.Add(tag, tag);
                            }
                            log.GenerateGetkeysByTagsAPILogItem(tags, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), responseResult);
                        }
                    }
                }
                catch
                {
                }
            }
        }
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.UnRegisterBulkKeyNotifCommand unRegisterBulkKeyNotifCommand = command.unRegisterBulkKeyNotifCommand;

            cmdInfo.Keys             = unRegisterBulkKeyNotifCommand.keys.ToArray();
            cmdInfo.RemoveCallbackId = (short)unRegisterBulkKeyNotifCommand.removeCallbackId;
            cmdInfo.RequestId        = unRegisterBulkKeyNotifCommand.requestId.ToString();
            cmdInfo.UpdateCallbackId = (short)unRegisterBulkKeyNotifCommand.updateCallbackId;

            return(cmdInfo);
        }
Example #52
0
 public SearchTransactions(IdentityMap im, ClientManager clientManager)
 {
     _im            = im;
     _clientManager = clientManager;
 }
Example #53
0
 public void Initialize()
 {
     ClientManager.SetCurrent("NvBX2hFF44SVvTPtYjF0zQ");
 }
Example #54
0
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.RemoveGroupCommand removeGroupCommand = command.removeGroupCommand;
            cmdInfo.Group            = removeGroupCommand.group;
            cmdInfo.RequestId        = removeGroupCommand.requestId.ToString();
            cmdInfo.SubGroup         = removeGroupCommand.subGroup.Length == 0 ? null : removeGroupCommand.subGroup;
            cmdInfo.ClientLastViewId = command.clientLastViewId;

            return(cmdInfo);
        }
Example #55
0
 public HotSeatPlayer()
 {
     this.playerColor        = PlayerColor.White;
     clientManager           = ClientManager.getInstance();
     clientManager.ActEvent += OnPlayerAct;
 }
Example #56
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("LockCommand", "command: " + command + " Error" + arEx);
                }
                _lockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //   _resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(arEx, base.immatureId), base.ParsingExceptionMessage(arEx));
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }
            catch (Exception exc)
            {
                _lockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            try
            {
                NCache   nCache           = clientManager.CmdExecuter as NCache;
                object   lockId           = null;
                DateTime lockDate         = DateTime.Now;
                var      operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress);
                bool res = nCache.Cache.Lock(cmdInfo.Key, cmdInfo.LockTimeout, out lockId, out lockDate, operationContext);

                //PROTOBUF:RESPONSE
                Alachisoft.NCache.Common.Protobuf.VerifyLockResponse verifyLockResponse = new Alachisoft.NCache.Common.Protobuf.VerifyLockResponse();

                verifyLockResponse.lockId         = lockId.ToString();
                verifyLockResponse.success        = res;
                verifyLockResponse.lockExpiration = lockDate.Ticks;

                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(verifyLockResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(verifyLockResponse, Common.Protobuf.Response.Type.LOCK_VERIFY));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.lockVerify = verifyLockResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.LOCK_VERIFY);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                _lockResult = OperationResult.Failure;
                //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
        }
Example #57
0
 public ClientSelector(ClientManager clientManager)
 {
     _clientManager = clientManager;
 }
Example #58
0
        public static void EndAuction(Client client)
        {
            if (client.Player.CharID == AuctionMaster || Ranks.IsAllowed(client, Enums.Rank.Developer))
            {
                if (client.Player.MapID == AUCTION_MAP)
                {
                    if (State == AuctionState.Pending)
                    {
                        State         = AuctionState.NotStarted;
                        AuctionMaster = null;

                        IMap playerMap = client.Player.Map;
                        foreach (Client i in playerMap.GetClients())
                        {
                            Messenger.PlayerMsg(i, "The auction has ended.", Text.Yellow);
                            //Messenger.SendBattleDivider(i);
                            //Messenger.PlayerMsg(client, "The auction has been ended!", Text.Yellow);
                        }
                    }
                    else if (State == AuctionState.Started)
                    {
                        State = AuctionState.NotStarted;
                        //LastAuctionMaster = AuctionMaster;
                        AuctionMaster = null;
                        // if (Ranks.IsDisallowed(client, Enums.Rank.Developer)) {
                        //  AuctionMaster = null;
                        // }
                        IMap playerMap = client.Player.Map;
                        foreach (Client i in playerMap.GetClients())
                        {
                            Messenger.PlayerMsg(i, "The auction has ended. The winner was " + ClientManager.FindClient(highestBidder).Player.Name + " with a bid of " + highestBid.ToString(), Text.Yellow);
                            Messenger.SendBattleDivider(i);
                            //Messenger.PlayerMsg(client, "The auction has been ended!", Text.Yellow);
                        }
                    }
                }
                else
                {
                    Messenger.PlayerMsg(client, "No auction has been started yet!", Text.BrightRed);
                }
            }
        }
Example #59
0
 public void Initialize()
 {
     ClientManager.SetCurrent("VJ63zukvLyxz92NKP1k0EQ");
 }
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            //HACK:notifMask
            Alachisoft.NCache.Common.Protobuf.RegisterNotifCommand registerNotifCommand = command.registerNotifCommand;
            cmdInfo.RegNotifs  = registerNotifCommand.notifMask;
            cmdInfo.RequestId  = registerNotifCommand.requestId.ToString();
            cmdInfo.datafilter = registerNotifCommand.datafilter;
            cmdInfo.sequence   = registerNotifCommand.sequence;
            return(cmdInfo);
        }