Example #1
0
        /// <inheritdoc />
        protected override void OnEventFired(object source, PlayerWorldSessionCreationEventArgs args)
        {
            EntityCreationData data = new EntityCreationData(args.EntityGuid, MovementDataMappable[args.EntityGuid], EntityDataUpdateFactory.Create(new EntityFieldUpdateCreationContext(EntityDataMappable[args.EntityGuid], EntityDataMappable[args.EntityGuid].DataSetIndicationArray)));

            var senderContext = new GenericSingleTargetMessageContext <PlayerSelfSpawnEventPayload>(args.EntityGuid, new PlayerSelfSpawnEventPayload(data));

            Sender.Send(senderContext);
        }
        /// <inheritdoc />
        public async Task SendAsync(GenericSingleTargetMessageContext <TPayloadType> context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (!SessionMappable.ContainsKey(context.EntityGuid))
            {
                LogNoSessionError(context.EntityGuid);
            }
            else
            {
                //Should we configure await false?
                //TODO: Develivery method?
                await SessionMappable[context.EntityGuid].SendMessage(context.PayloadToSend)
                .ConfigureAwait(false);
            }
        }
        /// <inheritdoc />
        public void Send(GenericSingleTargetMessageContext <TPayloadType> context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (!SessionMappable.ContainsKey(context.EntityGuid))
            {
                LogNoSessionError(context.EntityGuid);
            }
            else
            {
                //We MUST unwrap the task otherwise we will not get exceptions. Which is BAD.
                //TODO: Develivery method?
                SessionMappable[context.EntityGuid].SendMessageImmediately(context.PayloadToSend)
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();
            }
        }