Exemple #1
0
 /// <inheritdoc />
 protected override async void OnEventFired(object source, EventArgs args)
 {
     //TODO: Check result
     //We don't need to be on the main thread to send a session claim request.
     await SendService.SendMessage(new ClientSessionClaimRequestPayload(AuthTokenRepository.RetrieveWithType(), CharacterDataRepository.CharacterId))
     .ConfigureAwait(false);
 }
 private async Task SendNetworkedMenuClick(MenuItemIdentifier buttonIdentifier)
 {
     //We should just send that we clicked this menu id.
     //if it's successful it should redirect connection to that ship.
     //We must properly handle redirection to move the scene forward.
     await SendService.SendMessage(new SharedMenuSelectionRequestPayload(buttonIdentifier));
 }
Exemple #3
0
        private void HandleGameListResponse(BlockGameListResponsePayload response)
        {
            //TODO: This is just for testing, we try to join the first one list
            GameListEntry entry = response.GameEntries.First();

            SendService.SendMessage(new SharedMenuSelectionRequestPayload(entry.Listing), DeliveryMethod.ReliableOrdered);
        }
        protected override void OnEventFired(object source, EventArgs args)
        {
            //Once connection to the instance server is established
            //we must attempt to claim out session on to actually fully enter.
            EventQueueable.Enqueue(async() =>
            {
                try
                {
                    CharacterListResponse listResponse = await CharacterService.GetCharacters();

                    await CharacterService.TryEnterSession(listResponse.CharacterIds.First());

                    CharacterDataRepository.UpdateCharacterId(listResponse.CharacterIds.First());

                    //TODO: When it comes to community servers, we should not expose the sensitive JWT to them. We need a better way to deal with auth against untrusted instance servers
                    await SendService.SendMessage(new ClientSessionClaimRequestPayload(AuthTokenRepository.RetrieveWithType(), listResponse.CharacterIds.First()));
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to authenticate to instance server as character. Reason: {e.ToString()}");
                    }

                    throw;
                }
            });
        }
Exemple #5
0
        private IEnumerator BroadcastTransformPosition()
        {
            while (true)
            {
                if (Vector3.Magnitude(lastPosition - transform.position) > Vector3.kEpsilon)
                {
                    lastPosition     = transform.position;
                    isFinishedMoving = false;
                    SendService.SendMessage(new Sub60MovingFastPositionSetCommand(Identity.EntityId,
                                                                                  UnitScaler.UnScaleYtoZ(transform.position)).ToPayload());
                }
                else if (!isFinishedMoving)
                {
                    lastPosition     = transform.position;
                    isFinishedMoving = true;

                    //TODO: Handle rotation
                    //Send a stop if we stopped moving
                    SendService.SendMessage(new Sub60FinishedMovingCommand(Identity.EntityId,
                                                                           UnitScaler.ScaleYRotation(transform.rotation.eulerAngles.y),
                                                                           UnitScaler.UnScale(transform.position).ToNetworkVector3(), RoomQueryService.RoomIdForPlayerById(Identity.EntityId), ZoneData.ZoneId).ToPayload());
                }

                yield return(new WaitForSeconds(1.0f / BroadcastsPerSecond));
            }
        }
Exemple #6
0
        protected override void OnEventFired(object source, EntityCreationFinishedEventArgs args)
        {
            GameObject entity = GameObjectMappable.RetrieveEntity(args.EntityGuid);

            //Adding a test/demo collider to allow for a clicking volume.
            BoxCollider collider = entity.AddComponent <BoxCollider>();

            collider.isTrigger = true;
            entity.AddComponent <OnMouseClickedComponent>().OnMouseClicked += (sender, eventArgs) =>
            {
                if (eventArgs.Type == MouseButtonClickEventArgs.MouseType.Left)
                {
                    //Check if they are selectable
                    if (!EntityDataFieldMappable.RetrieveEntity(args.EntityGuid).HasBaseObjectFieldFlag(BaseObjectFieldFlags.UNIT_FLAG_NOT_SELECTABLE))
                    {
                        SendService.SendMessage(new ClientInteractNetworkedObjectRequestPayload(args.EntityGuid, ClientInteractNetworkedObjectRequestPayload.InteractType.Selection));

                        //Client side prediction of player target
                        LocalPlayerDetails.EntityData.SetFieldValue(EntityObjectField.UNIT_FIELD_TARGET, args.EntityGuid);
                    }
                }
                else
                {
                    //Check if the entity is interactable before sending a packet.
                    if (EntityDataFieldMappable.RetrieveEntity(args.EntityGuid).HasBaseObjectFieldFlag(BaseObjectFieldFlags.UNIT_FLAG_INTERACTABLE))
                    {
                        SendService.SendMessage(new ClientInteractNetworkedObjectRequestPayload(args.EntityGuid, ClientInteractNetworkedObjectRequestPayload.InteractType.Interaction));
                    }
                }
            };
        }
Exemple #7
0
        public void ClickMenuItem(uint menuId, uint itemId)
        {
            //Disable the ship panel
            MenuPanelObject.SetActive(false);

            //Send the menu selection request. The server will redirect us if it's success.
            SendService.SendMessage(new SharedMenuSelectionRequestPayload(new MenuItemIdentifier(menuId, itemId)));
        }
Exemple #8
0
    public bool Send()
    {
        // An object which interfaces with the web service
        SendService ss = new SendService();

        // The sending of the message (A synchronous event - We wait untill finished)
        return(ss.SendMessage("*****@*****.**", "d1a1n1", this.from, this.To, this.msg));
    }
Exemple #9
0
        public void SendChatMessage(string message)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            SendService.SendMessage(new BlockTextChatMessageRequestPayload(message));
        }
        public void SendCharacterSelection()
        {
            if (Logger.IsDebugEnabled)
            {
                Logger.Debug($"Sending CharSelection: {SelectedModel.SlotSelected}");
            }

            //Just send the request
            SendService.SendMessage(new CharacterCharacterSelectionRequestPayload((byte)SelectedModel.SlotSelected, CharacterSelectionType.PlaySelection));
        }
Exemple #11
0
        protected override void OnEventFired(object source, EventArgs args)
        {
            //Once connection to the instance server is established
            //we must attempt to claim out session on to actually fully enter.

            //We send time sync first since we need to have a good grasp of the current network time before
            //we even spawn into the world and start recieveing the world states.
            SendService.SendMessageImmediately(new ServerTimeSyncronizationRequestPayload(DateTime.UtcNow.Ticks))
            .ConfigureAwaitFalse();

            //TODO: When it comes to community servers, we should not expose the sensitive JWT to them. We need a better way to deal with auth against untrusted instance servers
            SendService.SendMessage(new ClientSessionClaimRequestPayload(AuthTokenRepository.RetrieveWithType(), CharacterDataRepository.CharacterId));
        }
Exemple #12
0
        /// <inheritdoc />
        protected override void OnEventFired(object source, LoginResultEventArgs args)
        {
            if (!args.isSuccessful)
            {
                return;
            }

            if (Logger.IsInfoEnabled)
            {
                Logger.Info($"OnLogin: Sending {nameof(CharacterCharacterSelectionRequestPayload)} with Id: {SlotModel.SlotSelected}");
            }

            SendService.SendMessage(new CharacterCharacterSelectionRequestPayload(SlotModel.SlotSelected, CharacterSelectionType.PlaySelection))
            .ConfigureAwait(false);
        }
Exemple #13
0
        protected override void OnEventFired(object source, MovementInputChangedEventArgs args)
        {
            //We send remote time instead of remoteTime + latency because
            //our client is going to move right away and we want EVERYONE
            //to view us as if we had started moving at the same time as the
            //local client percieves it.
            long timeStamp = TimeService.CurrentRemoteTime;

            //We also are going to send a position hint to the server.
            //Server has authority in rejecting this hint, and it should if it finds its
            //WAY off. However this is how we deal with the issue of desyncronization
            //by having the client be semi-authorative about where it is.
            WorldTransform entity = TransformMap.RetrieveEntity(PlayerDetails.LocalPlayerGuid);

            SendService.SendMessage(new ClientMovementDataUpdateRequest(new Vector2(args.NewHorizontalInput, args.NewVerticalInput), timeStamp, new Vector3(entity.PositionX, entity.PositionY, entity.PositionZ)));
        }
        private async void Send()
        {
            TelegramClient client = await Client.GetClient();

            int usersCount = _userSearchResult.TlUsers.Count;

            if (_sendModel.Interval != TimeSpan.Zero)
            {
                CancellationTokenSource tokenSource = new CancellationTokenSource();
                string promptMessage = $"Сообщения будут отправлены {usersCount} пользователям";

                if (MakeSureToSendMessages(promptMessage))
                {
                    ClearSendForm();
                    NavidateHome();
                    await _sendService.RunPeriodically(client, _sendModel, _userSearchResult, tokenSource.Token);
                }
            }
            else
            {
                string promptMessage = $"Отправить сейчас сообщение {usersCount} пользователям?";
                if (MakeSureToSendMessages(promptMessage))
                {
                    List <UserModel> users = await _sendService.SendMessage(client, _sendModel, _userSearchResult);

                    if (users.Count > 0)
                    {
                        MessageBox.Show($"Отправлено", MessageBoxConstants.Information,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Question);
                        ClearSendForm();
                    }
                    else
                    {
                        MessageBox.Show("Сообщение не отправлено ни одному пользователю", MessageBoxConstants.Information,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Question);
                    }
                    ClearSendForm();
                    NavidateHome();
                }
            }
        }
        /// <inheritdoc />
        protected override async void OnEventFired(object source, LocalPlayerWorldObjectSpawnedEventArgs args)
        {
            //TODO: We should extract this into a warping service.

            //TODO: Send rotation
            //TODO: What should the W coord be? How sould we handle this poition?
            //We can't do anything with the data right now
            await SendService.SendMessage(new Sub60TeleportToPositionCommand((byte)EntityGuid.GetEntityId(args.EntityGuid),
                                                                             ScalerService.UnScale(args.WorldObject.transform.position).ToNetworkVector3()).ToPayload());

            //Now we have to send a 1F to start the warp
            //Tell the server we're warping now
            await SendService.SendMessage(new Sub60WarpToNewAreaCommand((byte)EntityGuid.GetEntityId(args.EntityGuid), ZoneSettings.ZoneId).ToPayload());

            //TODO: is it save to send this in the lobby??
            await SendService.SendMessage(new Sub60FinishedMapLoadCommand(EntityGuid.GetEntityId(args.EntityGuid)).ToPayload());

            //TODO: Should we send ClientId with this one too?
            //We can just send a finished right away, we have nothing to load really
            await SendService.SendMessage(new Sub60FinishedWarpingBurstingCommand((byte)EntityGuid.GetEntityId(args.EntityGuid)).ToPayload());
        }
Exemple #16
0
        protected override void OnActionBarButtonPressed(ActionBarIndex index)
        {
            //If we have a set index then we can just send the request to interact/cast
            if (ActionBarCollection.IsSet(index))
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug($"Action bar Index: {index} pressed.");
                }

                if (ActionBarCollection[index].Type == ActionBarIndexType.Spell)
                {
                    SendService.SendMessage(new SpellCastRequestPayload(ActionBarCollection[index].ActionId));
                }
            }
            else
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug($"Action bar Index: {index} pressed but no associated action.");
                }
            }
        }
        /// <inheritdoc />
        public override void OnPlayerEnter(INetworkPlayer player)
        {
            if (!player.isLocalPlayer)
            {
                return;
            }

            Logger.Info("About to send kick packet");

            //See: http://answers.unity3d.com/questions/15822/how-to-get-the-positive-or-negative-angle-between.html
            float angle = AngleSigned(Vector3.forward, (player.Transform.Position - transform.position), Vector3.up);

            Logger.Info($"Angle of Kick: {angle}");

            //Frames since birth; PSOBB expects 30fps
            int frames = (int)(30.0f * (Time.time - BirthTime));

            SendService.SendMessage(new Sub60LobbySoccerBallMoveEventPayload((byte)player.Identity.EntityId, (short)frames, Scaler.UnScaleYRotation(angle),
                                                                             Scaler.UnScaleYtoZ(transform.position)).ToPayload());

            //Also kick the ball on the client
            GetComponent <IKickable>().Kick(transform.position, angle);
        }
Exemple #18
0
 public void Test3F()
 {
     SendService.SendMessage(new Sub60TeleportToPositionCommand((byte)SlotModel.SlotSelected, new Vector3 <float>(Position.x, Position.y, Position.z)).ToPayload());
 }
 /// <inheritdoc />
 public Task StopMovementAsync(Vector3 position, Quaternion rotation)
 {
     return(SendService.SendMessage(new Sub60FinishedMovingCommand(PlayerSlotModel.SlotSelected,
                                                                   UnitScaler.ScaleYRotation(rotation.eulerAngles.y),
                                                                   UnitScaler.UnScale(position).ToNetworkVector3(), RoomQueryService.RoomIdForPlayerById(PlayerSlotModel.SlotSelected), ZoneData.ZoneId).ToPayload()));
 }
Exemple #20
0
        /// <inheritdoc />
        protected override void OnEventFired(object source, MovementInputChangedEventArgs args)
        {
            Logger.Info($"About to send movement change.");

            SendService.SendMessage(new ClientMovementDataUpdateRequest(new Vector2(args.isMoving ? args.NewHorizontalInput : 0.0f, args.isMoving ? args.NewVerticalInput : 0.0f)));
        }
Exemple #21
0
        protected override void OnEventFired(object source, CameraInputChangedEventArgs args)
        {
            WorldTransform entity = TransformMappable.RetrieveEntity(PlayerDetails.LocalPlayerGuid);

            SendService.SendMessage(new ClientRotationDataUpdateRequest(args.Rotation, TimeService.CurrentRemoteTime, new Vector3(entity.PositionX, entity.PositionY, entity.PositionZ)));
        }
 /// <inheritdoc />
 public Task UpdatedMovementLocation(Vector3 position, Quaternion rotation)
 {
     return(SendService.SendMessage(new Sub60MovingFastPositionSetCommand(PlayerSlotModel.SlotSelected,
                                                                          UnitScaler.UnScaleYtoZ(position)).ToPayload()));
 }