示例#1
0
        public override void OnSetProperties(ISetPropertiesCallInfo info)
        {
            base.OnSetProperties(info);

            var setPropertiesRequest = info.Request;
            var url = this.gamePropertiesUrl;

            if (setPropertiesRequest.HttpForward && !string.IsNullOrEmpty(url))
            {
                var state = WebFlags.ShouldSendState(info.Request.WebFlags) ? this.GetGameState() : null;

                this.PostJsonRequest(
                    url,
                    new WebhooksRequest
                {
                    Type        = info.Request.ActorNumber == 0 ? "Game" : "Actor",
                    TargetActor = info.Request.ActorNumber == 0 ? null : (int?)info.Request.ActorNumber,
                    GameId      = this.PluginHost.GameId,
                    AppId       = this.AppId,
                    AppVersion  = this.AppVersion,
                    Region      = this.Region,
                    UserId      = info.UserId,
                    Nickname    = info.Nickname,
                    ActorNr     = info.ActorNr,
                    Properties  = setPropertiesRequest.Properties,
                    State       = state,
                    AuthCookie  = WebFlags.ShouldSendAuthCookie(info.Request.WebFlags) ? info.AuthCookie : null,
                },
                    this.LogIfFailedCallback,
                    null,
                    callAsync: !WebFlags.ShouldSendSync(info.Request.WebFlags));
            }
        }
示例#2
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            base.OnRaiseEvent(info);

            var raiseEventRequest = info.Request;
            var url = this.gameEventUrl;

            if (raiseEventRequest.HttpForward && !string.IsNullOrEmpty(url))
            {
                var state = WebFlags.ShouldSendState(info.Request.WebFlags) ? this.GetGameState() : null;

                this.PostJsonRequest(
                    url,
                    new WebhooksRequest
                {
                    Type       = "Event",
                    GameId     = this.PluginHost.GameId,
                    AppId      = this.AppId,
                    AppVersion = this.AppVersion,
                    Region     = this.Region,
                    UserId     = info.UserId,
                    Nickname   = info.Nickname,
                    ActorNr    = info.ActorNr,
                    Data       = raiseEventRequest.Data,
                    State      = state,
                    AuthCookie = WebFlags.ShouldSendAuthCookie(info.Request.WebFlags) ? info.AuthCookie : null,
                    EvCode     = raiseEventRequest.EvCode,
                },
                    this.LogIfFailedCallback,
                    null,
                    callAsync: !WebFlags.ShouldSendSync(info.Request.WebFlags));
            }
        }