Exemplo n.º 1
0
 public void Echo(string message) => OnEcho?.Invoke(message);
Exemplo n.º 2
0
        /// <summary>
        /// Main callback handler.
        /// </summary>
        /// <param name="call"></param>
        /// <returns></returns>
        private async Task GbxRemoteClient_OnCallback(MethodCall call)
        {
            switch (call.Method)
            {
            case "ManiaPlanet.PlayerConnect":
            case "TrackMania.PlayerConnect":
                OnPlayerConnect?.Invoke(
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[0]),
                    (bool)XmlRpcTypes.ToNativeValue <bool>(call.Arguments[1])
                    );
                break;

            case "ManiaPlanet.PlayerDisconnect":
            case "TrackMania.PlayerDisconnect":
                OnPlayerDisconnect?.Invoke(
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[0]),
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[1])
                    );
                break;

            case "ManiaPlanet.PlayerChat":
            case "TrackMania.PlayerChat":
                OnPlayerChat?.Invoke(
                    (int)XmlRpcTypes.ToNativeValue <int>(call.Arguments[0]),
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[1]),
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[2]),
                    (bool)XmlRpcTypes.ToNativeValue <bool>(call.Arguments[3])
                    );
                break;

            case "ManiaPlanet.Echo":
            case "TrackMania.Echo":
                OnEcho?.Invoke(
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[0]),
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[1])
                    );
                break;

            case "ManiaPlanet.BeginMatch":
            case "TrackMania.BeginMatch":
                OnBeginMatch?.Invoke();
                break;

            case "ManiaPlanet.EndMatch":
            case "TrackMania.EndMatch":
                OnEndMatch?.Invoke(
                    (SPlayerRanking[])XmlRpcTypes.ToNativeValue <SPlayerRanking>(call.Arguments[0]),
                    (int)XmlRpcTypes.ToNativeValue <int>(call.Arguments[1])
                    );
                break;

            case "ManiaPlanet.BeginMap":
            case "TrackMania.BeginMap":
                OnBeginMap?.Invoke(
                    (SMapInfo)XmlRpcTypes.ToNativeValue <SMapInfo>(call.Arguments[0])
                    );
                break;

            case "ManiaPlanet.EndMap":
            case "TrackMania.EndMap":
                OnEndMap?.Invoke(
                    (SMapInfo)XmlRpcTypes.ToNativeValue <SMapInfo>(call.Arguments[0])
                    );
                break;

            case "ManiaPlanet.StatusChanged":
            case "TrackMania.StatusChanged":
                OnStatusChanged?.Invoke(
                    (int)XmlRpcTypes.ToNativeValue <int>(call.Arguments[0]),
                    (string)XmlRpcTypes.ToNativeValue <string>(call.Arguments[1])
                    );
                break;

            case "ManiaPlanet.PlayerInfoChanged":
            case "TrackMania.PlayerInfoChanged":
                OnPlayerInfoChanged?.Invoke(
                    (SPlayerInfo)XmlRpcTypes.ToNativeValue <SPlayerInfo>(call.Arguments[0])
                    );
                break;

            case "ManiaPlanet.ModeScriptCallback":
            case "TrackMania.ModeScriptCallback":
                await HandleModeScriptCallback(call);

                break;

            case "ManiaPlanet.ModeScriptCallbackArray":
            case "TrackMania.ModeScriptCallbackArray":
                await HandleModeScriptCallback(call);

                break;
            }

            // always invoke the OnAnyCallback event
            OnAnyCallback?.Invoke(call, (object[])XmlRpcTypes.ToNativeValue <object>(
                                      new XmlRpcArray(call.Arguments)
                                      ));
        }