コード例 #1
0
ファイル: RemoteConsole.cs プロジェクト: Gutbuster/Oxide
 public void SendMessage(RemoteMessage message) => Sessions.Broadcast(message.ToJSON());
コード例 #2
0
ファイル: RemoteConsole.cs プロジェクト: crazyants/Oxide
        /// <summary>
        /// Handles messages sent from the clients
        /// </summary>
        /// <param name="e"></param>
        private void OnMessage(MessageEventArgs e, WebSocketContext connection)
        {
            var message = RemoteMessage.GetMessage(e.Data);

            message.Message = message.Message.Replace("\"", string.Empty);

            if (message == null || covalence == null || string.IsNullOrEmpty(message.Message))
            {
                Interface.Oxide.LogError($"[Rcon] Failed to process command {(message == null ? "RemoteMessage" : "Covalence")} is null");
                return;
            }

            var msg  = message.Message.Split(' ');
            var cmd  = msg[0].ToLower();
            var args = msg.Skip(1).ToArray();

            if (Interface.CallHook("OnRconCommand", connection.UserEndPoint.Address, cmd, args) != null)
            {
                return;
            }

            switch (cmd)
            {
            case "broadcast":
            case "chat.say":
            case "global.say":
            case "say":
                BroadcastMessage(cmd, args, message.Identifier, connection);
                break;

            case "global.playerlist":
            case "playerlist":
                PlayerListCommand(cmd, args, message.Identifier, connection);
                break;

            case "hostname":
            case "server.hostname":
                HostnameCommand(cmd, args, message.Identifier, connection);
                break;

            case "global.kick":
            case "kick":
                KickCommand(cmd, args, message.Identifier, connection);
                break;

            case "save":
            case "server.save":
                covalence.Server.Save();
                SendMessage(connection, "Server saved", message.Identifier);
                break;

            case "ban":
            case "banid":
            case "global.ban":
            case "global.banid":
                BanCommand(cmd, args, message.Identifier, connection);
                break;

            case "global.unban":
            case "unban":
                UnbanCommand(cmd, args, message.Identifier, connection);
                break;

            case "server.version":
            case "version":
                SendMessage(connection, $"{covalence.Game} {covalence.Server.Version} - Protocol {covalence.Server.Protocol} with Oxide v{OxideMod.Version}", message.Identifier);
                break;

            case "global.teleport":
            case "global.teleportpos":
            case "teleport":
            case "teleportpos":
                TeleportCommand(cmd, args, message.Identifier, connection);
                break;

            default:
                covalence.Server.Command(cmd, args);
                break;
            }
        }