Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
0
        public override void OnLeave(ILeaveGameCallInfo info)
        {
            base.OnLeave(info);

            var url = this.gameLeaveUrl;

            if (!string.IsNullOrEmpty(url)) // && info.ActorNr != -1 we don't restrict this anymore as in forwardplugin to see all leaves
            {
                this.PostJsonRequest(
                    url,
                    new WebhooksRequest
                {
                    Type       = LeaveReason.ToString(info.Reason),
                    GameId     = this.PluginHost.GameId,
                    AppId      = this.AppId,
                    AppVersion = this.AppVersion,
                    Region     = this.Region,
                    UserId     = info.UserId,
                    Nickname   = info.Nickname,
                    ActorNr    = info.ActorNr,
                    IsInactive = info.IsInactive,
                    Reason     = info.Reason.ToString(),
                    AuthCookie = WebFlags.ShouldSendAuthCookie(info.Request.WebFlags) ? info.AuthCookie : null,
                },
                    this.LogIfFailedCallback,
                    callAsync: true);
            }
        }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
0
        private string SerializeRequest(WebRpcRequest request, string userId, object authResultsSecure)
        {
            if (request.RpcParams != null && typeof(Dictionary <string, object>) == request.RpcParams.GetType())
            {
                var rpcParams = (Dictionary <string, object>)request.RpcParams;

                rpcParams["AppId"]      = this.environment == null ? null : this.environment["AppId"];
                rpcParams["AppVersion"] = this.environment == null ? null : this.environment["AppVersion"];
                rpcParams["Region"]     = this.environment == null ? null : this.environment["Region"];
                rpcParams["UserId"]     = userId;
                if (WebFlags.ShouldSendAuthCookie(request.WebFlags))
                {
                    rpcParams["AuthCookie"] = authResultsSecure;
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(rpcParams));
            }
            else
            {
                var rpcParams = new Dictionary <string, object>();

                rpcParams["AppId"]      = this.environment == null ? null : this.environment["AppId"];
                rpcParams["AppVersion"] = this.environment == null ? null : this.environment["AppVersion"];
                rpcParams["Region"]     = this.environment == null ? null : this.environment["Region"];
                rpcParams["UserId"]     = userId;
                if (WebFlags.ShouldSendAuthCookie(request.WebFlags))
                {
                    rpcParams["AuthCookie"] = authResultsSecure;
                }
                if (request.RpcParams != null)
                {
                    rpcParams["RpcParams"] = request.RpcParams;
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(rpcParams));
            }
        }