Example #1
0
        /// <summary>
        /// 类型:方法
        /// 名称:TryEnter
        /// 作者:taixihuase
        /// 作用:通过角色数据尝试进入场景
        /// 编写日期:2015/7/22
        /// </summary>
        /// <param name="operationRequest"></param>
        /// <param name="sendParameters"></param>
        /// <param name="peer"></param>
        private static void TryEnter(OperationRequest operationRequest, SendParameters sendParameters, ServerPeer peer)
        {
            ServerPeer.Log.Debug("Entering");

            int uniqueId = (int)
                Serialization.Deserialize(operationRequest.Parameters[(byte) ParameterCode.WorldEnter]);

            Character character;
            if (peer.Server.Characters.CharacterEnter(uniqueId, out character))
            {
                peer.Server.Data.CharacterData.GetCharacterPosition(character);
            }

            // 返回数据给客户端

            byte[] pos = Serialization.Serialize(character.Position);

            OperationResponse reponseData = new OperationResponse((byte) OperationCode.WorldEnter,
                new Dictionary<byte, object>
                {
                    {(byte) ParameterCode.WorldEnter, pos}
                })
            {
                ReturnCode = (short) ErrorCode.Ok,
                DebugMessage = "进入场景成功"
            };
            peer.SendOperationResponse(reponseData, sendParameters);

            byte[] data = Serialization.Serialize(character);
            EventData eventData = new EventData((byte) EventCode.WorldEnter, new Dictionary<byte, object>
            {
                {(byte) ParameterCode.WorldEnter, data}
            });
            eventData.SendTo(peer.Server.Characters.GamingClientsToBroadcast, sendParameters);
        }
        public void JoinGameWithLobby()
        {
            string roomName = CreateRandomRoomName();

            TestClient client = this.InitClient();

            var request = new OperationRequest { OperationCode = (byte)OperationCode.Join, Parameters = new Dictionary<byte, object>() };
            request.Parameters.Add((byte)ParameterKey.GameId, roomName);
            request.Parameters.Add((byte)LobbyParameterKeys.LobbyId, "Mainlobby");
            client.SendOperationRequest(request);
            OperationResponse response = client.WaitForOperationResponse(this.WaitTime);
            EventData eventArgs = client.WaitForEvent(this.WaitTime);

            // check operation params
            CheckDefaultOperationParameters(response, OperationCode.Join);
            CheckParam(response, ParameterKey.ActorNr, 1);

            // check event params
            CheckDefaultEventParameters(eventArgs, OperationCode.Join, 1);
            CheckEventParamExists(eventArgs, ParameterKey.Actors);

            // cleanup
            client.Close();
            client.Dispose();
        }
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            WriteLog("Receive RequestCode:" + (OperationCode) operationRequest.OperationCode);
            HandlerBase handler;
            ArpgApplication.Instance.Handlers.TryGetValue(operationRequest.OperationCode, out handler);

            if (handler != null)
            {
                //1.处理
                var response = handler.OnHandlerMeesage(operationRequest, this);

                //2.发送响应
                SendOperationResponse(response, sendParameters);

                //3.日志记录
                object subCode = null;
                WriteLog(string.Format("Rsponse operationCode:{0} success",
                    (OperationCode) operationRequest.OperationCode));
            }
            else
            {
                //1.异常,日志记录
                WriteLog(string.Format("Can not find OperationCode:{0}",
                    (OperationCode) operationRequest.OperationCode));
            }
        }
        public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer)
        {
            object json;
            request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json);
            var user = JsonMapper.ToObject<User>(json.ToString());
            var response = new OperationResponse {OperationCode = request.OperationCode};

            //查询数据库
            var userDb = _manager.GetUserByUsername(user.Username);
            if (userDb == null)
            {
                if (_manager.RegisterUser(user))
                {
                    response.ReturnCode = (short) ReturnCode.Success;
                    peer.SetUser(user);
                }
                else
                {
                    response.ReturnCode = (short) ReturnCode.Eception;
                    response.DebugMessage = "异常";
                }
            }
            else
            {
                response.ReturnCode = (short) ReturnCode.Fail;
                response.DebugMessage = "用户名已存在!";
            }
            return response;
        }
        public void JoinGameWithLobby()
        {
            string roomName = CreateRandomRoomName();

            TestClient client = this.InitClient();

            OperationRequest request = new OperationRequest((short)OperationCodes.Join);
            request.Params.Add((short)ParameterKeys.GameId, roomName);
            request.Params.Add((short)LiteLobby.Operations.LobbyParameterKeys.LobbyId, "Mainlobby");
            client.SendOperationRequest(request, 0, true);
            OperationResponse response = client.WaitForOperationResponse(this.WaitTime);
            EventReceivedEventArgs eventArgs = client.WaitForEvent(this.WaitTime);

            // check operation params
            CheckDefaultOperationParams(response, OperationCodes.Join);
            CheckParam(response, ParameterKeys.ActorNr, 1);

            // check event params
            CheckDefaultEventParams(eventArgs, OperationCodes.Join, 1);
            CheckEventParamExists(eventArgs, ParameterKeys.Actors);

            // cleanup
            client.Close();
            client.Dispose();
        }
Example #6
0
        /// <summary>
        /// 类型:方法
        /// 名称:TryRegist
        /// 作者:taixihuase
        /// 作用:通过请求的角色数据,尝试创建、记录一个新的角色数据并再次返回给客户端
        /// 编写日期:2015/7/14
        /// </summary>
        /// <param name="operationRequest"></param>
        /// <param name="sendParameters"></param>
        /// <param name="peer"></param>
        private static void TryRegist(OperationRequest operationRequest, SendParameters sendParameters, ServerPeer peer)
        {
            ServerPeer.Log.Debug("Regist a new account...");

            RegistInfo info = (RegistInfo)
                Serialization.Deserialize(operationRequest.Parameters[(byte) ParameterCode.Regist]);

            UserCollection.UserReturn userReturn = peer.Server.Users.RegistUser(info);

            if (userReturn.ReturnCode == UserCollection.UserReturn.ReturnCodeType.Success)
            {
                OperationResponse response = new OperationResponse((byte)OperationCode.Regist)
                {
                    ReturnCode = (short)ErrorCode.Ok,
                    DebugMessage = "账号创建成功!"
                };

                peer.SendOperationResponse(response, sendParameters);
            }
            else
            {
                OperationResponse response = new OperationResponse((byte)OperationCode.Regist)
                {
                    ReturnCode = (short)ErrorCode.InvalidOperation,
                    DebugMessage = userReturn.DebugMessage.ToString()
                };
                peer.SendOperationResponse(response, sendParameters);
                ServerPeer.Log.Debug(DateTime.Now + " : Failed to regist " + info.Account + " Because of " +
                                     Enum.GetName(typeof(UserCollection.UserReturn.ReturnCodeType),
                                         userReturn.ReturnCode));
            }
        }
Example #7
0
 /// <summary>
 ///   Handles all operations that are not allowed before operation <see cref = "EnterWorld" /> is called.
 /// </summary>
 /// <param name = "request">
 ///   The request.
 /// </param>
 /// <returns>
 ///   An <see cref = "OperationResponse" /> with <see cref = "ReturnCode.InvalidOperation" />.
 /// </returns>
 public static OperationResponse InvalidOperation(OperationRequest request)
 {
     return new OperationResponse(request.OperationCode)
         {
            ReturnCode = (int)ReturnCode.InvalidOperation, DebugMessage = "InvalidOperation: " + (OperationCode)request.OperationCode 
         };
 }
Example #8
0
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            switch (operationRequest.OperationCode)
            {
                default:
                    {
                        string message = string.Format("Unknown operation code {0}", operationRequest.OperationCode);
                        this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = message }, sendParameters);
                        break;
                    }

                case 1:
                    {
                        var pingOperation = new LatencyOperation(this.Protocol, operationRequest.Parameters);
                        if (pingOperation.IsValid == false)
                        {
                            this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = pingOperation.GetErrorMessage() }, sendParameters);
                            return;
                        }

                        Thread.Sleep(5);

                        var response = new OperationResponse(operationRequest.OperationCode, pingOperation);
                        this.SendOperationResponse(response, sendParameters);
                        break;
                    }
            }
        }
Example #9
0
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnOperationRequest. Code={0}", operationRequest.OperationCode);
            }

            switch (operationRequest.OperationCode)
            {
                case (byte)MyOperationCodes.EchoOperation:
                    {
                        // The echo operation one is handled immediately because it does not require the client to join a game.
                        var myEchoRequest = new MyEchoRequest(this.Protocol, operationRequest);
                        if (this.ValidateOperation(myEchoRequest, sendParameters) == false)
                        {
                            return;
                        }

                        var myEchoResponse = new MyEchoResponse { Response = myEchoRequest.Text };
                        var operationResponse = new OperationResponse(operationRequest.OperationCode, myEchoResponse);
                        this.SendOperationResponse(operationResponse, sendParameters);
                        break;
                    }

                default:
                    {
                        // for this example all other operations will handled by the base class
                        base.OnOperationRequest(operationRequest, sendParameters);
                        return;
                    }
            }
        }
Example #10
0
        public async Task HandleConfirmJoinOperation(GamePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            var joinRequest = new ConfirmJoinRequest(peer.Protocol, operationRequest);
            if (!peer.ValidateOperation(joinRequest, sendParameters))
            {
                return;
            }

            //string playerInfoStr = await WebHelper.RequestPlayerInfo(joinRequest.UserKey);
            string playerInfoStr = "{ \"username\": \"test\", \"game_money\": 2000 }";

            PlayerInfo info = JsonConvert.DeserializeObject<PlayerInfo>(playerInfoStr);

            PeerManager.Instance.OnPeerJoin(peer, new PeerInfo(peer, joinRequest.RoomID, joinRequest.UserKey));

            var room = FindRoom(joinRequest.RoomID);

            if (room != null)
            {
                room.ExecutionFiber.Enqueue(() => room.Join(peer, joinRequest, sendParameters, info));
            }
            else
            {
                var response = new OperationResponse(CommonOperationCode.ConfirmJoin,
                new Dictionary<byte, object> { { (byte)CommonParameterKey.Success, false } });
                peer.SendOperationResponse(response, sendParameters);
            }
        }
Example #11
0
        public virtual void HandleOperationRequest(GamePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            switch (operationRequest.OperationCode)
            {
                case CommonOperationCode.Join:
                    HandleJoinOperation(peer, operationRequest, sendParameters);
                    break;

                case CommonOperationCode.Exit:
                    HandleExitOperation(peer, operationRequest, sendParameters);
                    break;

                case CommonOperationCode.Chat:
                    HandleChatOperation(peer, operationRequest, sendParameters);
                    break;

                case CommonOperationCode.GetRooms:
                    SendAllRoomStatus(peer, sendParameters);
                    break;

                case CommonOperationCode.ConfirmJoin:
                    var task = HandleConfirmJoinOperation(peer, operationRequest, sendParameters);
                    task.Wait();
                    break;
            }
        }
 private EntityScreen UpdateEntityScreens(OperationRequest<Entity> value)
 {
     var entityScreens =
         _applicationState.IsLocked ?
         _applicationState.GetTicketEntityScreens().ToList() :
         _applicationState.GetEntityScreens().ToList();
     if (!entityScreens.Any()) return null;
     _entityScreens = entityScreens.OrderBy(x => x.SortOrder).ToList();
     _entitySwitcherButtons = null;
     var selectedScreen = _applicationState.SelectedEntityScreen;
     if (value != null && value.SelectedItem != null && _applicationState.CurrentDepartment != null)
     {
         if (_applicationState.IsLocked || _applicationState.CurrentDepartment.TicketCreationMethod == 1)
             _entityScreens = _entityScreens.Where(x => x.EntityTypeId == value.SelectedItem.EntityTypeId).OrderBy(x => x.SortOrder);
         if (!_entityScreens.Any())
             return entityScreens.ElementAt(0);
         if (selectedScreen == null || selectedScreen.EntityTypeId != value.SelectedItem.EntityTypeId)
         {
             selectedScreen = null;
             if (!string.IsNullOrEmpty(value.Data))
             {
                 selectedScreen = _entityScreens.Where(x => x.DisplayMode == 1).FirstOrDefault(x => x.EntityTypeId == value.SelectedItem.EntityTypeId);
             }
             if (selectedScreen == null)
             {
                 selectedScreen = _entityScreens.FirstOrDefault(x => x.EntityTypeId == value.SelectedItem.EntityTypeId);
             }
         }
         if (selectedScreen == null) selectedScreen = _entityScreens.ElementAt(0);
     }
     return selectedScreen ?? EntityScreens.ElementAt(0);
 }
        protected override void OnOperationRequest(OperationRequest request, SendParameters sendParameters)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnOperationRequest: pid={0}, op={1}", this.ConnectionId, request.OperationCode);
            }

            switch ((OperationCode)request.OperationCode)
            {
                default:
                    var response = new OperationResponse(request.OperationCode) { ReturnCode = (short)ErrorCode.OperationInvalid, DebugMessage = "Unknown operation code" };
                    this.SendOperationResponse(response, sendParameters);
                    break;

                case OperationCode.Authenticate:
                    OperationResponse authenticateResponse = this.HandleAuthenticate(request);
                    this.SendOperationResponse(authenticateResponse, sendParameters);
                    break;

                case OperationCode.CreateGame:
                case OperationCode.JoinLobby:
                case OperationCode.LeaveLobby:
                case OperationCode.JoinRandomGame:
                case OperationCode.JoinGame:
                    this.lobby.EnqueueOperation(this, request, sendParameters);
                    break;
            }
        }
        public EntitySearchWidgetViewModel(Widget model, IApplicationState applicationState, ICacheService cacheService, IEntityService entityService)
            : base(model, applicationState)
        {
            _applicationState = applicationState;
            _cacheService = cacheService;
            EntitySearchViewModel = new EntitySearchViewModel(applicationState, cacheService, entityService) { IsKeyboardVisible = false };
            
            EventServiceFactory.EventService.GetEvent<GenericEvent<OperationRequest<Entity>>>().Subscribe(x =>
            {
                if (x.Topic == EventTopicNames.SelectEntity)
                {
                    _request = x.Value;
                }
            });

            EventServiceFactory.EventService.GetEvent<GenericEvent<WidgetEventData>>().Subscribe(
                x =>
                {
                    if (x.Value.WidgetName == Name)
                    {
                        EntitySearchViewModel.SearchString = x.Value.Value;
                       
                    }
                });
        }
        public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer)
        {
            //1.获得客户端发送的帐号和明文密码
            object json;
            request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json);
            var user = JsonMapper.ToObject<User>(json.ToString());
            var userDb = _manager.GetUserByUsername(user.Username);
            var s = userDb != null
                ? string.Format("user.Username:{0},user.Password:{1} userDb.Username:{2},userDb.Password:{3}",
                    user.Username, user.Password, userDb.Username, userDb.Password)
                : "未找到用户:" + user.Username;
            peer.WriteLog(s);

            //2.比较,然后创建响应
            var response = new OperationResponse {OperationCode = request.OperationCode};
            if (userDb != null && userDb.Password == MD5Tool.GetMD5(user.Password))
            {
                response.ReturnCode = (short) ReturnCode.Success;
                peer.SetUser(userDb);
            }
            else
            {
                response.ReturnCode = (short) ReturnCode.Fail;
                response.DebugMessage = "用户名或密码错误!";
            }

            return response;
        }
 public override void OnHandleRequest(OperationRequest request)
 {
     Log.Debug("SubServerLogin Handler sending response of 1");
     var para = new Dictionary<byte, object>
                    {{(byte) ParameterCode.UserId, request.Parameters[(byte) ParameterCode.UserId]}};
     _peer.SendOperationResponse(new OperationResponse(1) {Parameters = para}, new SendParameters {ChannelId = 0, Unreliable = false});
 }
Example #17
0
        protected override void OnOperationRequest(OperationRequest request, SendParameters sendParameters)
        {
            switch (request.OperationCode)
            {
                case (byte)OperationCode.Authenticate:
                    this.HandleAuthenticateOperation(request, sendParameters);
                    return;

                case (byte)OperationCode.CreateGame:
                    this.HandleCreateGameOperation(request, sendParameters);
                    return;

                case (byte)OperationCode.JoinGame:
                    this.HandleJoinGameOperation(request, sendParameters);
                    return;

                case (byte)Lite.Operations.OperationCode.Leave:
                    this.HandleLeaveOperation(request, sendParameters);
                    return;

                case (byte)Lite.Operations.OperationCode.Ping:
                    this.HandlePingOperation(request, sendParameters);
                    return;

                case (byte)OperationCode.DebugGame:
                    this.HandleDebugGameOperation(request, sendParameters);
                    return;

                case (byte)SPOperationCode.UpdateFlightControls:
                this.HandleGameOperation(request, sendParameters);
                    return;
            }

            base.OnOperationRequest(request, sendParameters);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SetPropertiesRequest"/> class.
        /// </summary>
        /// <param name="protocol">
        /// The protocol.
        /// </param>
        /// <param name="operationRequest">
        /// Operation request containing the operation parameters.
        /// </param>
        public SetPropertiesRequest(IRpcProtocol protocol, OperationRequest operationRequest)
            : base(protocol, operationRequest)
        {
            if (!this.IsValid)
            {
                return;
            }

            // special handling for game and actor properties send by AS3/Flash (Amf3 protocol) or JSON clients
            if (protocol.ProtocolType == ProtocolType.Amf3V16 || protocol.ProtocolType == ProtocolType.Json)
            {
                if (this.UpdatingGameProperties)
                {
                    Utilities.ConvertAs3WellKnownPropertyKeys(this.Properties, null);
                    Utilities.ConvertAs3WellKnownPropertyKeys(this.ExpectedValues, null);
                }
                else
                {
                    Utilities.ConvertAs3WellKnownPropertyKeys(null, this.Properties);
                    Utilities.ConvertAs3WellKnownPropertyKeys(null, this.ExpectedValues);
                }
            }

            if (this.UpdatingGameProperties)
            {
                this.isValid = GameParameterReader.TryGetProperties(this.Properties, out this.newMaxPlayer,
                    out this.newIsOpen, out this.newIsVisible,
                    out this.newLobbyProperties, out this.MasterClientId,
                    out this.ExpectedUsers, out this.errorMessage);
            }
        }
Example #19
0
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            var operationCode = (OperationCode) operationRequest.OperationCode;

            if (_context == null)
            {
                if (operationCode != OperationCode.SetupContext)
                    throw new ArgumentException($"Failed to process operation request '{operationCode}', the context has not been initialized");

                var contextType = (ContextType) operationRequest.Parameters[(byte) OperationParameterCode.ContextType];

                if (contextType == ContextType.InstanceServer)
                    _context = new InstanceClientContext(_application, this);
                else if (contextType == ContextType.RegionServer)
                    _context = new RegionClientContext(_application, this);
                else if (contextType == ContextType.PlayerClient)
                    _context = new PlayerClientContext(_application, this);
                else if (contextType == ContextType.ConsoleClient)
                    _context = new ConsoleClientContext(_application, this);
                else
                    throw new ArgumentException($"Failed setup context type '{contextType}', the context type was not recognized");

                return;
            }

            _context.OnOperationRequest(operationCode, operationRequest.Parameters);
        }
 public void OnOperationRequest(StarCollectorPeer sender, OperationRequest operationRequest, SendParameters sendParameters)
 {
     executionFiber.Enqueue(() =>
     {
         this.ProcessMessage(sender,
             operationRequest, sendParameters);
     });
 }
Example #21
0
 public static OperationRequest CreateWorld(string worldName, BoundingBox boundingBox, Vector tileDimensions)
 {
     var request = new OperationRequest { OperationCode = (byte)OperationCode.CreateWorld, Parameters = new Dictionary<byte, object>() };
     request.Parameters.Add((byte)ParameterCode.WorldName, worldName);
     request.Parameters.Add((byte)ParameterCode.BoundingBox, boundingBox);
     request.Parameters.Add((byte)ParameterCode.TileDimensions, tileDimensions);
     return request;
 }
Example #22
0
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            switch ((DiscussionOpCode) operationRequest.OperationCode)
            {
                case DiscussionOpCode.Test:
                    var operation = new TestOperation(this.Protocol, operationRequest);
                    if (ValidateOperation(operation, sendParameters))
                    {
                        SendOperationResponse(operation.GetResponse(), sendParameters);
                        return;
                    }
                    break;
                case DiscussionOpCode.NotifyUserAccPlusMinus:
                case DiscussionOpCode.NotifyStructureChanged:
                case DiscussionOpCode.NotifyArgPointChanged:
                case DiscussionOpCode.CursorRequest:
                case DiscussionOpCode.CreateShapeRequest:
                case DiscussionOpCode.DeleteShapesRequest:
                case DiscussionOpCode.UnselectAllRequest:
                case DiscussionOpCode.DeleteSingleShapeRequest:
                case DiscussionOpCode.StateSyncRequest:
                case DiscussionOpCode.InitialSceneLoadRequest:
                case DiscussionOpCode.LinkCreateRequest:
                case DiscussionOpCode.UnclusterBadgeRequest:
                case DiscussionOpCode.ClusterBadgeRequest:
                case DiscussionOpCode.ClusterMoveRequest:
                case DiscussionOpCode.InkRequest:
                case DiscussionOpCode.DEditorReport:
                case DiscussionOpCode.ClusterStatsRequest:
                case DiscussionOpCode.LinkReportRequest:
                case DiscussionOpCode.BadgeViewRequest:
                case DiscussionOpCode.ExplanationModeSyncViewRequest:
                case DiscussionOpCode.CommentReadRequest:
                case DiscussionOpCode.AttachLaserPointerRequest:
                case DiscussionOpCode.DetachLaserPointerRequest:
                case DiscussionOpCode.LaserPointerMovedRequest:
                case DiscussionOpCode.ImageViewerManipulateRequest:
                case DiscussionOpCode.ImageViewerStateRequest:
                case DiscussionOpCode.BrowserScrollChanged:
                case DiscussionOpCode.GetBrowserScrollPos:
                case DiscussionOpCode.PdfScrollChanged:
                case DiscussionOpCode.GetPdfScrollPos:  
                    HandleGameOperation(operationRequest, sendParameters);
                    break;
                case DiscussionOpCode.NotifyLeaveUser:
                    handleOnlineStatus(_photonPer, _dbId, false, (int) DeviceType.Sticky);
                    break;
                case DiscussionOpCode.StatsEvent:
                    if (LogEvent(operationRequest.Parameters))
                        HandleGameOperation(operationRequest, sendParameters); // broadcast stats event
                    break;
                case DiscussionOpCode.ScreenshotRequest:
                    HandleScreenshotRequest(operationRequest, sendParameters);
                    break;            
            }

            base.OnOperationRequest(operationRequest, sendParameters);
        }
Example #23
0
 /// <summary>
 /// The create world.
 /// </summary>
 /// <param name="worldName">
 /// The world name.
 /// </param>
 /// <param name="topLeftCorner">
 /// The top left corner.
 /// </param>
 /// <param name="bottomRightCorner">
 /// The bottom right corner.
 /// </param>
 /// <param name="tileDimensions">
 /// The tile dimensions.
 /// </param>
 /// <returns>
 /// the OperationRequest
 /// </returns>
 public static OperationRequest CreateWorld(string worldName, float[] topLeftCorner, float[] bottomRightCorner, float[] tileDimensions)
 {
     var request = new OperationRequest { OperationCode = (byte)OperationCode.CreateWorld, Parameters = new Dictionary<byte, object>() };
     request.Parameters.Add((byte)ParameterCode.WorldName, worldName);
     request.Parameters.Add((byte)ParameterCode.TopLeftCorner, topLeftCorner);
     request.Parameters.Add((byte)ParameterCode.BottomRightCorner, bottomRightCorner);
     request.Parameters.Add((byte)ParameterCode.TileDimensions, tileDimensions);
     return request;
 }
Example #24
0
        private void Authenticate()
        {
            var request = new OperationRequest
            {
                OperationCode = (byte)Operations.OperationCode.Authenticate
            };

            this.masterClient.SendOperationRequest(request, new SendParameters());
        }
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            IPhotonRequestHandler handler;

            if (RequestHandlers.TryGetValue(operationRequest.OperationCode, out handler))
            {
                handler.HandleRequest(operationRequest);
            }
        }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "GetPropertiesRequest" /> class.
 /// </summary>
 /// <param name = "protocol">
 ///   The protocol.
 /// </param>
 /// <param name = "operationRequest">
 ///   Operation request containing the operation parameters.
 /// </param>
 public GetPropertiesRequest(IRpcProtocol protocol, OperationRequest operationRequest)
     : base(protocol, operationRequest)
 {
     // special treatment for game and actor properties sent by AS3/Flash or JSON clients
     if (protocol.ProtocolType == ProtocolType.Amf3V16 || protocol.ProtocolType == ProtocolType.Json)
     {
         Utilities.ConvertAs3WellKnownPropertyKeys(this.GamePropertyKeys, this.ActorPropertyKeys);
     }
 }
Example #27
0
 protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
 {
     switch (operationRequest.OperationCode)
     {
         case LGOperationCode.GetRooms:
             //GameServerManager.gameCore.SendAllRoomStatus(this, sendParameters);
             break;
     }
 }
        public static OperationResponse HandleUnknownOperationCode(OperationRequest operationRequest, ILogger logger)
        {
            if (logger != null && logger.IsDebugEnabled)
            {
                logger.DebugFormat("Unknown operation code: OpCode={0}", operationRequest.OperationCode);
            }

            return new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = (int)ErrorCode.OperationInvalid, DebugMessage = "Invalid operation code" };
        }
        /// <summary>
        /// Kicks the actor from the world (event WorldExited is sent to the client) and then disconnects the client.
        /// </summary>
        /// <remarks>
        /// Called by DisconnectByOtherPeer after being enqueued to the PeerBase.RequestFiber.
        /// It kicks the actor from the world (event WorldExited) and then continues the original request by calling the original peer's OnOperationRequest method.        
        /// </remarks>
        public void OnDisconnectByOtherPeer(PeerBase otherPeer, OperationRequest otherRequest, SendParameters sendParameters)
        {
            this.ExitWorld();

            // disconnect peer after the exit world event is sent
            this.Peer.RequestFiber.Enqueue(() => this.Peer.RequestFiber.Enqueue(this.Peer.Disconnect));

            // continue execution of other request
            PeerHelper.InvokeOnOperationRequest(otherPeer, otherRequest, sendParameters);
        }
    public void SendGetList()
    {
        Dictionary<byte, object> parametes = new Dictionary<byte, object>();

        parametes.Add((byte)ClientParameterCode.SubOperationCode, MessageSubCode.ListCharacters);

        OperationRequest request = new OperationRequest {OperationCode = (byte)ClientOperationCode.Login, Parameters = parametes};

        SendOperation(request, true, 0, true);
    }
 internal LoginAccountOperation(IRpcProtocol protocol, OperationRequest request) : base(protocol, request)
 {
 }
Example #32
0
        /// <summary>
        ///   Called for each operation in the execution queue.
        ///   Every <see cref = "Room" /> has a queue of incoming operations to execute.
        ///   Per game <see cref = "ExecuteOperation" /> is never executed multi-threaded, thus all code executed here has thread safe access to all instance members.
        /// </summary>
        /// <param name = "peer">
        ///   The peer.
        /// </param>
        /// <param name = "operationRequest">
        ///   The operation request to execute.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        protected override void ExecuteOperation(LitePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            try
            {
                base.ExecuteOperation(peer, operationRequest, sendParameters);

                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("Executing operation {0}", (OperationCode)operationRequest.OperationCode);
                }

                switch ((OperationCode)operationRequest.OperationCode)
                {
                case OperationCode.Join:
                {
                    var joinRequest = new JoinRequest(peer.Protocol, operationRequest);
                    if (peer.ValidateOperation(joinRequest, sendParameters) == false)
                    {
                        return;
                    }

                    if (this.logQueue.Log.IsDebugEnabled)
                    {
                        this.logQueue.Add(
                            new LogEntry(
                                "ExecuteOperation: " + (OperationCode)operationRequest.OperationCode,
                                "Peer=" + peer.ConnectionId));
                    }

                    joinRequest.OnStart();
                    this.HandleJoinOperation(peer, joinRequest, sendParameters);
                    joinRequest.OnComplete();
                    break;
                }

                case OperationCode.Leave:
                {
                    var leaveOperation = new LeaveRequest(peer.Protocol, operationRequest);
                    if (peer.ValidateOperation(leaveOperation, sendParameters) == false)
                    {
                        return;
                    }

                    if (this.logQueue.Log.IsDebugEnabled)
                    {
                        this.logQueue.Add(
                            new LogEntry(
                                "ExecuteOperation: " + (OperationCode)operationRequest.OperationCode,
                                "Peer=" + peer.ConnectionId));
                    }

                    leaveOperation.OnStart();
                    this.HandleLeaveOperation(peer, leaveOperation, sendParameters);
                    leaveOperation.OnComplete();
                    break;
                }

                case OperationCode.RaiseEvent:
                {
                    var raiseEventOperation = new RaiseEventRequest(peer.Protocol, operationRequest);
                    if (peer.ValidateOperation(raiseEventOperation, sendParameters) == false)
                    {
                        return;
                    }

                    raiseEventOperation.OnStart();
                    this.HandleRaiseEventOperation(peer, raiseEventOperation, sendParameters);
                    raiseEventOperation.OnComplete();
                    break;
                }

                case OperationCode.GetProperties:
                {
                    var getPropertiesOperation = new GetPropertiesRequest(peer.Protocol, operationRequest);
                    if (peer.ValidateOperation(getPropertiesOperation, sendParameters) == false)
                    {
                        return;
                    }

                    getPropertiesOperation.OnStart();
                    this.HandleGetPropertiesOperation(peer, getPropertiesOperation, sendParameters);
                    getPropertiesOperation.OnComplete();
                    break;
                }

                case OperationCode.SetProperties:
                {
                    var setPropertiesOperation = new SetPropertiesRequest(peer.Protocol, operationRequest);
                    if (peer.ValidateOperation(setPropertiesOperation, sendParameters) == false)
                    {
                        return;
                    }

                    setPropertiesOperation.OnStart();
                    this.HandleSetPropertiesOperation(peer, setPropertiesOperation, sendParameters);
                    setPropertiesOperation.OnComplete();
                    break;
                }

                case OperationCode.Ping:
                {
                    peer.SendOperationResponse(new OperationResponse {
                            OperationCode = operationRequest.OperationCode
                        }, sendParameters);
                    break;
                }

                case OperationCode.ChangeGroups:
                {
                    var changeGroupsOperation = new ChangeGroups(peer.Protocol, operationRequest);
                    if (peer.ValidateOperation(changeGroupsOperation, sendParameters) == false)
                    {
                        return;
                    }

                    changeGroupsOperation.OnStart();
                    this.HandleChangeGroupsOperation(peer, changeGroupsOperation, sendParameters);
                    changeGroupsOperation.OnComplete();
                    break;
                }

                default:
                {
                    string message = string.Format("Unknown operation code {0}", (OperationCode)operationRequest.OperationCode);
                    peer.SendOperationResponse(
                        new OperationResponse {
                            OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = message
                        }, sendParameters);

                    if (Log.IsWarnEnabled)
                    {
                        Log.Warn(message);
                    }
                }

                break;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Example #33
0
 public abstract void OnHandlerMessage(OperationRequest _request, OperationResponse _response, Clientpeer _peer,
                                       SendParameters _sendparameters);
        public override OperationResponse Handle(MmoActor actor, OperationRequest request, SendParameters sendParameters)
        {
            var operation = new ExecAction(actor.Peer.Protocol, request);

            if (!operation.IsValid)
            {
                return(new OperationResponse(request.OperationCode)
                {
                    ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage()
                });
            }

            operation.OnStart();
            //CL.Out("exec action called: " + operation.Action);

            Item item;
            bool actorItem = actor.TryGetItem((byte)ItemType.Avatar, operation.ItemId, out item);

            if (actorItem == false)
            {
                if (actor.World.ItemCache.TryGetItem((byte)ItemType.Avatar, operation.ItemId, out item) == false)
                {
                    //return new OperationResponse((byte)OperationCode.ExecAction) { ReturnCode = (short)ReturnCode.ItemNotFound, DebugMessage = "ItemNotFound" };
                    Hashtable methodResult = null;
                    var       method       = actor.ActionExecutor.GetType().GetMethod(operation.Action);

                    if (method != null)
                    {
                        object respObject = method.Invoke(actor.ActionExecutor, operation.Parameters);
                        if (respObject != null && respObject is Hashtable)
                        {
                            methodResult = respObject as Hashtable;
                            ExecActionResponse response = new ExecActionResponse {
                                Result = methodResult, Action = operation.Action, ItemId = string.Empty
                            };
                            return(new OperationResponse(OperationCode.ExecAction.toByte(), response)
                            {
                                ReturnCode = (int)ReturnCode.Ok,
                                DebugMessage = string.Format("Action completed when no avatar")
                            });
                        }
                    }
                    return(new OperationResponse(OperationCode.ExecAction.toByte(), new ExecActionResponse {
                        Result = new Hashtable(),
                        Action = operation.Action, ItemId = string.Empty
                    })
                    {
                        ReturnCode = (int)ReturnCode.Fatal,
                        DebugMessage = "Method not found",
                    });
                }
            }
            if (actorItem)
            {
                if (item is MmoItem)
                {
                    return(this.ItemOperationExecAction(item as MmoItem, operation, actor));
                }
                else
                {
                    return(new OperationResponse((byte)OperationCode.ExecAction, new ExecActionResponse {
                        Result = new Hashtable(), Action = operation.Action, ItemId = string.Empty
                    })
                    {
                        ReturnCode = (short)ReturnCode.Fatal,
                        DebugMessage = "Actor item Item not MmoItem"
                    });
                }
            }

            if (item is MmoItem)
            {
                MmoItem mmoItem = item as MmoItem;
                item.Fiber.Enqueue(() => actor.ExecItemOperation(() => this.ItemOperationExecAction(mmoItem, operation, actor), sendParameters));
                return(null);
            }
            else
            {
                return(new OperationResponse((byte)OperationCode.ExecAction, new ExecActionResponse {
                    Action = operation.Action, ItemId = string.Empty, Result = new Hashtable()
                })
                {
                    ReturnCode = (short)ReturnCode.Fatal,
                    DebugMessage = "Foreign Actor item Item not MmoItem"
                });
            }
        }
Example #35
0
 public HammerBashRequest(string actionSource, IRpcProtocol protocol, OperationRequest request)
     : base(actionSource, protocol, request)
 {
 }
 public override void SendOperationRequest(OperationRequest operationRequest, bool reliable = true, bool encrypt = false, byte channel = 0)
 {
     photonPeer.OpCustom(operationRequest, reliable, channel, encrypt);
 }
Example #37
0
 protected virtual void ExecuteOperation(
     PlayerPeer peer,
     OperationRequest operation,
     SendParameters sendParameters)
 {
 }
Example #38
0
 public RegisterSubServer(IRpcProtocol rpcProtocol, OperationRequest operationRequest)
     : base(rpcProtocol, operationRequest)
 {
 }
Example #39
0
 public void DisplayTicketDetailsScreen(OperationRequest <SelectedOrdersData> currentOperationRequest)
 {
     _selectedOrdersViewModel.CurrentOperationRequest = currentOperationRequest;
     _regionManager.ActivateRegion(RegionNames.PosSubRegion, _selectedOrdersView);
     _ticketNoteEditorView.TicketNote.BackgroundFocus();
 }
Example #40
0
        public async Task Parallel_Request_DifferentSockets()
        {
            // arrange
            CancellationToken ct = new CancellationTokenSource(20_000).Token;

            using IWebHost host = TestServerHelper
                                  .CreateServer(
                      x => x.AddTypeExtension <StringSubscriptionExtensions>(),
                      out int port);

            ServiceCollection serviceCollection = new();

            serviceCollection
            .AddProtocol <GraphQLWebSocketProtocolFactory>();

            for (var i = 0; i < 10; i++)
            {
                serviceCollection.AddWebSocketClient(
                    "Foo" + i,
                    c => c.Uri = new Uri("ws://localhost:" + port + "/graphql"));
            }

            IServiceProvider services = serviceCollection.BuildServiceProvider();

            ISessionPool sessionPool = services.GetRequiredService <ISessionPool>();
            ConcurrentDictionary <int, List <JsonDocument> > results = new();

            async Task?CreateSubscription(int client, int id)
            {
                var connection =
                    new WebSocketConnection(async ct =>
                                            await sessionPool.CreateAsync("Foo" + client, ct));
                var document =
                    new MockDocument($"subscription Test {{ onTest(id:{id.ToString()}) }}");
                var request = new OperationRequest("Test", document);

                await foreach (var response in connection.ExecuteAsync(request, ct))
                {
                    if (response.Body is not null)
                    {
                        results.AddOrUpdate(client * 100 + id,
                                            _ => new List <JsonDocument> {
                            response.Body
                        },
                                            (_, l) =>
                        {
                            l.Add(response.Body);
                            return(l);
                        });
                    }
                }
            }

            // act
            var list = new List <Task>();

            for (var i = 0; i < 5; i++)
            {
                for (var j = 0; j < 10; j++)
                {
                    list.Add(CreateSubscription(i, j));
                }
            }

            await Task.WhenAll(list);

            // assert
            var str = "";

            foreach (var sub in results.OrderBy(x => x.Key))
            {
                JsonDocument[] jsonDocuments = sub.Value.ToArray();

                str += "Operation " + sub.Key + "\n";
                for (var index = 0; index < jsonDocuments.Length; index++)
                {
                    str += "Operation " + jsonDocuments[index].RootElement + "\n";
                }
            }

            str.MatchSnapshot();
        }
Example #41
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            SubCode subcode = ParameterTool.GetSubcode(request.Parameters);

            ParameterTool.AddSubcode(response.Parameters, subcode);
            switch (subcode)
            {
            case SubCode.SendTeam:
                if (TaidouApplication.Instance.clientPeerListForTeam.Count >= 2)
                {
                    //取得list中的前两个peer  跟当前的peer进行组队
                    ClientPeer peer1 = TaidouApplication.Instance.clientPeerListForTeam[0];
                    ClientPeer peer2 = TaidouApplication.Instance.clientPeerListForTeam[1];
                    Team       t     = new Team(peer1, peer2, peer);
                    TaidouApplication.Instance.clientPeerListForTeam.RemoveRange(0, 2);
                    List <Role> roleList = new List <Role>();
                    foreach (var clientPeer in t.clientPeers)
                    {
                        roleList.Add(clientPeer.LoginRole);
                    }
                    ParameterTool.AddParameter(response.Parameters, ParameterCode.RoleList, roleList);
                    ParameterTool.AddParameter(response.Parameters, ParameterCode.MasterRoleID, t.masterRoleId, false);
                    response.ReturnCode = (short)ReturnCode.GetTeam;

                    SendEventByPeer(peer1, (OperationCode)response.OperationCode, SubCode.GetTeam, roleList, t.masterRoleId);
                    SendEventByPeer(peer2, (OperationCode)response.OperationCode, SubCode.GetTeam, roleList, t.masterRoleId);
                }
                else
                {
                    //当当前服务器可供组队的客户端不足的时候,把自身添加到集合中 等待组队
                    TaidouApplication.Instance.clientPeerListForTeam.Add(peer);
                    response.ReturnCode = (short)ReturnCode.WartingTeam;
                }
                break;

            case SubCode.CancelTeam:
                TaidouApplication.Instance.clientPeerListForTeam.Remove(peer);
                response.ReturnCode = (short)ReturnCode.Success;
                break;

            case SubCode.SyncPositionAndRotation:
                object posObj = null;
                request.Parameters.TryGetValue((byte)ParameterCode.Position, out posObj);
                object eulerAnglesObj = null;
                request.Parameters.TryGetValue((byte)ParameterCode.EulerAngles, out eulerAnglesObj);
                foreach (ClientPeer temp in peer.Team.clientPeers)
                {
                    if (temp != peer)
                    {
                        SendEventByPeer(temp, OpCode, SubCode.SyncPositionAndRotation, peer.LoginRole.ID, posObj, eulerAnglesObj);
                    }
                }
                break;

            case SubCode.SyncMoveAnimation:
                foreach (ClientPeer temp in peer.Team.clientPeers)
                {
                    if (temp != peer)
                    {
                        SendMoveAnimationEvent(temp, OpCode, SubCode.SyncMoveAnimation, peer.LoginRole.ID, request.Parameters);
                    }
                }
                break;

            case SubCode.SyncAnimation:
                request.Parameters.Add((byte)ParameterCode.RoleID, peer.LoginRole.ID);
                RequestTool.TransmitRequest(peer, request, OpCode);
                break;

            case SubCode.SendGameState:
                RequestTool.TransmitRequest(peer, request, OpCode);
                peer.Team.Dismiss();    //解散队伍
                break;
            }
        }
Example #42
0
        public static void RefreshGroupTemplates(string grpID, bool useWorker, params string[] viewTypesToRefresh)
        {
            string syscontentRoot    = "sys/AAA/";
            string currContainerName = StorageSupport.CurrActiveContainer.Name;
            string anonContainerName = GetCurrentAnonContainerName(); //StorageSupport.CurrAnonPublicContainer.Name;
            //"demopublicoip-aaltoglobalimpact-org";
            string groupTemplateLocation       = "grp/" + grpID + "/" + DefaultWebTemplateLocation;
            string groupSiteLocation           = "grp/" + grpID + "/" + DefaultWebSiteLocation;
            string groupSiteViewLocation       = groupSiteLocation + "/" + DefaultGroupViewLocation;
            string groupPublicTemplateLocation = "grp/" + grpID + "/" + DefaultPublicGroupTemplateLocation;
            string groupPublicSiteLocation     = "grp/" + grpID + "/" + DefaultPublicGroupSiteLocation;
            string groupPublicViewLocation     = groupPublicSiteLocation + "/" + DefaultPublicGroupViewLocation;
            string defaultPublicSiteLocation   = "grp/default/" + DefaultPublicGroupSiteLocation;
            //string groupWwwPublicTemplateLocation = "grp/" + grpID + "/" + DefaultPublicWwwTemplateLocation;
            //string groupWwwPublicSiteLocation = "grp/" + grpID + "/" + DefaultPublicWwwSiteLocation;
            //string groupWwwSiteViewLocation = groupWwwPublicSiteLocation + "/" + DefaultPublicWwwViewLocation;
            string aboutAuthTargetLocation = DefaultAboutTargetLocation;

            // Sync to group local template
            List <OperationRequest> operationRequests = new List <OperationRequest>();
            var localGroupTemplates = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultGroupTemplates, currContainerName, groupTemplateLocation, useWorker, false);
            // Render local template
            var renderLocalTemplates = SyncTemplatesToSite(currContainerName, groupTemplateLocation, currContainerName, groupSiteLocation, useWorker, true);
            // Sync public pages to group local template
            var publicGroupTemplates = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultPublicGroupTemplates, currContainerName, groupPublicTemplateLocation, useWorker, false);
            // Render local template
            var renderPublicTemplates = SyncTemplatesToSite(currContainerName, groupPublicTemplateLocation, currContainerName, groupPublicSiteLocation, useWorker, true);

            /*
             * // Sync public www-pages to group local template
             * var publicWwwTemplates = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultPublicWwwTemplates,
             *                                           currContainerName, groupWwwPublicTemplateLocation, useWorker, false);
             *
             * // Render local template
             * var renderWwwTemplates = SyncTemplatesToSite(currContainerName, groupWwwPublicTemplateLocation, currContainerName, groupWwwPublicSiteLocation, useWorker, true);
             */
            operationRequests.Add(localGroupTemplates);
            operationRequests.Add(renderLocalTemplates);
            operationRequests.Add(publicGroupTemplates);
            operationRequests.Add(renderPublicTemplates);
            //operationRequests.Add(publicWwwTemplates);
            //operationRequests.Add(renderWwwTemplates);
            foreach (string viewTypeToRefresh in viewTypesToRefresh)
            {
                OperationRequest refreshOp = RefreshDefaultViews(groupSiteViewLocation, viewTypeToRefresh, useWorker);
                operationRequests.Add(refreshOp);
                refreshOp = RefreshDefaultViews(groupPublicViewLocation, viewTypeToRefresh, useWorker);
                operationRequests.Add(refreshOp);
                //refreshOp = RefreshDefaultViews(groupWwwSiteViewLocation, viewTypeToRefresh, useWorker);
                //operationRequests.Add(refreshOp);
            }
            // Publish group public content
#if never // Moved to separate operations to be web-ui activated
            var publishPublicContent = SyncTemplatesToSite(currContainerName, groupPublicSiteLocation, anonContainerName, groupPublicSiteLocation, useWorker, false);
            operationRequests.Add(publishPublicContent);
            if (grpID == DefaultGroupID) // Currently also publish www
            {
                OperationRequest publishDefault = SyncTemplatesToSite(currContainerName, groupPublicSiteLocation, anonContainerName, defaultPublicSiteLocation, useWorker, false);
                operationRequests.Add(publishDefault);
                publishDefault = SyncTemplatesToSite(currContainerName, groupPublicSiteLocation, currContainerName,
                                                     aboutAuthTargetLocation, useWorker, false);
                operationRequests.Add(publishDefault);
                string defaultWwwContainerName = GetCurrentWwwContainerName();
                publishDefault = SyncTemplatesToSite(currContainerName, groupWwwPublicSiteLocation,
                                                     defaultWwwContainerName, "", useWorker, false);
                operationRequests.Add(publishDefault);
            }
#endif
            if (useWorker)
            {
                //QueueSupport.PutToOperationQueue(localGroupTemplates, renderLocalTemplates);
                QueueSupport.PutToOperationQueue(operationRequests.ToArray());
            }
        }
 public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, MyClient peer)
 {
     throw new NotImplementedException();
 }
Example #44
0
 public MoveItemFromStationToBankRequest(IRpcProtocol protocol, OperationRequest request)
     : base(protocol, request)
 {
 }
Example #45
0
 public BroadcastBetRequest(IRpcProtocol protocol, OperationRequest operationRequest)
     : base(protocol, operationRequest)
 {
 }
Example #46
0
 public void OnOperationRequest(StarCollectorDemoPeer sender, OperationRequest operationRequest, SendParameters sendParameters)
 {
     // schedule a message to be processed on the main thread
     executionFiber.Enqueue(() => { this.ProcessMessage(sender, operationRequest, sendParameters); });
 }
Example #47
0
 public void EnqueueOperation(PlayerPeer peer, OperationRequest operationRequest, SendParameters sendParameters)
 {
     ExecutionFiber.Enqueue(() => ExecuteOperation(peer, operationRequest, sendParameters));
 }
Example #48
0
 public LeaveWorld(IRpcProtocol protocol, OperationRequest operationRequest)
     : base(protocol, operationRequest)
 {
 }
 public CreateCharacterOperationRequest(IRpcProtocol protocol, OperationRequest operationRequest)
     : base(protocol, operationRequest)
 {
 }
Example #50
0
 public abstract void OnHandlerMessage(OperationRequest request, OperationResponse response, Peer peer, SendParameters sendParameters);
Example #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SetPropertiesRequest"/> class.
 /// </summary>
 /// <param name="protocol">
 /// The protocol.
 /// </param>
 /// <param name="operationRequest">
 /// Operation request containing the operation parameters.
 /// </param>
 public SetPropertiesRequest(IRpcProtocol protocol, OperationRequest operationRequest)
     : base(protocol, operationRequest)
 {
 }
Example #52
0
 public ChangeGuildMemberStatusOperationRequest(IRpcProtocol protocol, OperationRequest request)
     : base(protocol, request)
 {
 }
Example #53
0
 public void ProcessMessage(StarCollectorDemoPeer sender, OperationRequest operationRequest, SendParameters sendParameters)
 {
     // process messages here
 }
Example #54
0
    public void Update()
    {
        OperationRequest operationRequest;

        if ((PhotonEngine.Instance.IsServer) && (!_hasSentServerStatus))
        {
            operationRequest = new OperationRequest();

            operationRequest.OperationCode = 6;

            PhotonEngine.Instance.SendOp(operationRequest, true, 0, false);

            _hasSentServerStatus = true;
        }

        else if (!_hasRequestedMyPeerId)
        {
            operationRequest = new OperationRequest();

            operationRequest.OperationCode = 5;

            PhotonEngine.Instance.SendOp(operationRequest, true, 0, false);

            _hasRequestedMyPeerId = true;
        }

        else
        {
            operationRequest = new OperationRequest();

            operationRequest.OperationCode = 0;

            PhotonEngine.Instance.SendOp(operationRequest, false, 0, false);

            List <Guid>             peerIds      = ((PeerIdHandler)_controller.OperationHandlers[0]).PeerIds;
            Dictionary <Guid, bool> peerIdsAlive = ((PeerIdHandler)_controller.OperationHandlers[0]).PeerIdsAlive;

            for (int i = 0; i < peerIds.Count; ++i)
            {
                Guid peerId = peerIds[i];

                if (!peerIdsAlive[peerId])
                {
                    if (_players[peerId].GetComponent <HoverCarNetworkInterface>().IsLocalPeer)
                    {
                        Debug.Log("You were disconnected from the server.");
                    }

                    peerIds.RemoveAt(i);
                    peerIdsAlive.Remove(peerId);

                    _spawnsAvailable.Add(_spawnsTaken[peerId]);

                    _spawnsTaken.Remove(peerId);

                    _players[peerId].GetComponent <HoverCarNetworkInterface>().IsDestroyed = true;
                    _players.Remove(peerId);

                    ((PlayerInputHandler)_controller.OperationHandlers[1]).PlayerInputs.Remove(peerId);
                    ((PlayerTransformHandler)_controller.OperationHandlers[2]).PlayerTransforms.Remove(peerId);
                }

                else if ((!_players.ContainsKey(peerId)) && (_spawnsAvailable.Count > 0))
                {
                    CreatePlayer(peerId);
                }
            }
        }
    }
Example #55
0
 public GetServerListRequest(IRpcProtocol protocol, OperationRequest operationRequest)
     : base(protocol, operationRequest)
 {
 }
 public SetNewPriceOperationRequest(IRpcProtocol protocol, OperationRequest request)
     : base(protocol, request)
 {
 }
Example #57
0
 protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
 {
     base.OnOperationRequest(operationRequest, sendParameters);
 }
Example #58
0
 public EnterWorldRequest(IRpcProtocol protocol, OperationRequest request)
     : base(protocol, request)
 {
 }