コード例 #1
0
ファイル: UIController.cs プロジェクト: FeXyK/Authory
    public void ChatOnValueChanged()
    {
        string text;

        if (ChatType.text.Length > 2)
        {
            text = ChatType.text;

            if (text[0] == '/' && text[2] == ' ')
            {
                switch (text.ToLower()[1])
                {
                case 'p':
                    ChatMessageType = MasterMessageType.PrivateChat;
                    ChatType.text   = "";
                    ActivatePrivateChatLayout();
                    break;

                case 'g':
                    DisablePrivateChatLayout();
                    ChatMessageType = MasterMessageType.GlobalChat;
                    ChatType.text   = "";
                    break;

                case 'w':
                    DisablePrivateChatLayout();
                    ChatMessageType = MasterMessageType.WorldChat;
                    ChatType.text   = "";
                    break;
                }
            }
            ChatMessageTypeDropdown.value = (int)ChatMessageType;
        }
    }
コード例 #2
0
        /// <summary>
        /// Handles a new connection to the server.
        /// </summary>
        /// <param name="msgIn">Message that changed the connection status</param>
        private void HandleConnection(NetIncomingMessage msgIn)
        {
            Console.WriteLine("New Conection");
            Console.WriteLine(msgIn.MessageType);

            msgIn.SenderConnection.Approve();
            if (msgIn.SenderConnection.Status == NetConnectionStatus.Connected)
            {
                if (msgIn.SenderConnection.RemoteHailMessage != null)
                {
                    Console.WriteLine("Remote hail message arrived");
                    NetIncomingMessage hailMessage = msgIn.SenderConnection.RemoteHailMessage;
                    MasterMessageType  msgType     = (MasterMessageType)hailMessage.ReadByte();

                    switch (msgType)
                    {
                    case MasterMessageType.NewNodeConnection:
                        IncomingMessageHandler.NewServerNodeConnection(msgIn, hailMessage);
                        break;

                    case MasterMessageType.NewAccountConnection:
                        IncomingMessageHandler.NewAccountConnection(hailMessage, msgIn);
                        break;
                    }
                }
            }
        }
コード例 #3
0
ファイル: UIController.cs プロジェクト: FeXyK/Authory
    public void IncomingChatMessage(MasterMessageType msgType, string username, string message, string date = "")
    {
        if (date.Length == 0)
        {
            date = DateTime.Now.ToString("HH:mm");
        }


        switch (msgType)
        {
        case MasterMessageType.GlobalChat:
            ChatWindows[0].text += string.Format($"\n{date} <color=#E0B426>[Global]\t {username}: {message}</color>");
            break;

        case MasterMessageType.WorldChat:
            ChatWindows[0].text += string.Format($"\n{date} <color=#E06A10>[World]\t {username}: {message}</color>");
            break;

        case MasterMessageType.PrivateChat:
            if (username.ToLower() == Player.Name.ToLower())
            {
                ChatWindows[0].text += string.Format($"\n{date} <color=#E01FDA>[Private]\t To: {privateChatReceiver}: {message}</color>");
            }
            else
            {
                ChatWindows[0].text += string.Format($"\n{date} <color=#E01FDA>[Private]\t From: {username}: {message}</color>");
            }
            break;
        }
    }
コード例 #4
0
    //Chat
    public void ChatMessage(NetIncomingMessage msgIn, MasterMessageType masterMsgType)
    {
        string username = msgIn.ReadString();
        string message  = msgIn.ReadString();

        //string date = msgIn.ReadString();

        uiController.IncomingChatMessage(masterMsgType, username, message);
    }
コード例 #5
0
        /// <summary>
        /// When a character sends a message to the world chat.
        /// </summary>
        /// <param name="msgType"></param>
        /// <param name="msgIn"></param>
        public void WorldChat(MasterMessageType msgType, NetIncomingMessage msgIn)
        {
            Account account        = DataHandler.GetAccount(msgIn.SenderConnection);
            string  messageContent = msgIn.ReadString();

            if (account.ConnectedServerMap != null)
            {
                account.ConnectedServerMap.SendMessageToConnectedPlayers(account, msgType, messageContent);
            }
        }
コード例 #6
0
        /// <summary>
        /// When a character sends a message from the global chat.
        /// </summary>
        /// <param name="msgType"></param>
        /// <param name="msgIn"></param>
        public void GlobalChat(MasterMessageType msgType, NetIncomingMessage msgIn)
        {
            Account account        = DataHandler.GetAccount(msgIn.SenderConnection);
            string  messageContent = msgIn.ReadString();

            foreach (var map in DataHandler.Maps)
            {
                foreach (var mapServer in map.Value.OnlineChannels)
                {
                    mapServer.SendMessageToConnectedPlayers(account, msgType, messageContent);
                }
            }
        }
コード例 #7
0
ファイル: UIController.cs プロジェクト: FeXyK/Authory
    public void ChatSelectMessageType()
    {
        ChatMessageType = (MasterMessageType)ChatMessageTypeDropdown.value;

        if (ChatMessageType == MasterMessageType.PrivateChat)
        {
            ActivatePrivateChatLayout();
        }
        else
        {
            DisablePrivateChatLayout();
            ChatType.Select();
        }
    }
コード例 #8
0
        /// <summary>
        /// Sends chat message to the receivers
        /// </summary>
        public void SendChatMessage(Account messageFrom, MasterMessageType messageType, string messageContent, List <Character> receivers)
        {
            NetOutgoingMessage msgOut;

            foreach (var receiver in receivers)
            {
                msgOut = Server.CreateMessage();

                msgOut.Write((byte)messageType);

                msgOut.Write(messageFrom.ConnectedCharacter.Name);
                msgOut.Write(messageContent);

                Server.SendMessage(msgOut, receiver.Account.Connection, NetDeliveryMethod.ReliableOrdered);
            }
        }
コード例 #9
0
        private static MasterMessageUnion ReadReply(MasterMessageType responses, Stream stream)
        {
            var iterator = MessageStreamIterator <MasterMessageUnion> .FromStreamProvider(() => new UndisposableStream(stream));

            var union = iterator.First();

            if (union.Type == MasterMessageType.MasterErrorResult)
            {
                throw new RemoteNodeException(union.Exception.Message);
            }
            if (union.Type != responses)
            {
                throw new UnexpectedReplyException("Got reply " + union.Type + " but expected " + responses);
            }

            return(union);
        }
コード例 #10
0
ファイル: AuthorySender.cs プロジェクト: FeXyK/Authory
    public static void SendChatMessage(string message, MasterMessageType chatMsgType = MasterMessageType.GlobalChat, string receiverName = null)
    {
        if (MasterClient.ServerConnection != null)
        {
            NetOutgoingMessage msgOut = MasterClient.CreateMessage();

            //msgOut.Write(Data.Player.Name);
            msgOut.Write((byte)chatMsgType);
            msgOut.Write(message);

            if (chatMsgType == MasterMessageType.PrivateChat)
            {
                msgOut.Write(receiverName);
            }

            MasterClient.SendMessage(msgOut, NetDeliveryMethod.ReliableUnordered);
        }
    }
コード例 #11
0
        /// <summary>
        /// Handles a given NetIncomingMessage by its MasterMessageType
        /// </summary>
        /// <param name="msgType">Type of the message to be handled.</param>
        /// <param name="msgIn">The arrived Message</param>
        private void HandleMessage(MasterMessageType msgType, NetIncomingMessage msgIn)
        {
            switch (msgType)
            {
            //Client
            case MasterMessageType.GlobalChat:
                IncomingMessageHandler.GlobalChat(msgType, msgIn);
                break;

            //Client
            case MasterMessageType.WorldChat:
                IncomingMessageHandler.WorldChat(msgType, msgIn);
                break;

            //Client
            case MasterMessageType.PrivateChat:
                IncomingMessageHandler.PrivateChatMessage(msgIn);
                break;

            //Client
            case MasterMessageType.ServerConnectionRequest:
                IncomingMessageHandler.ServerConnectionRequest(msgIn);
                break;

            //MapServer
            case MasterMessageType.RequestCharacterInfo:
                IncomingMessageHandler.RequestCharacterInfoArrived(msgIn);
                break;

            //MapServer
            case MasterMessageType.MapChangeRequest:
                IncomingMessageHandler.MapChangeRequest(msgIn);
                break;

            //Client
            case MasterMessageType.CreateCharacter:
                IncomingMessageHandler.CreateCharacter(msgIn);
                break;

            //Client
            case MasterMessageType.DeleteCharacter:
                IncomingMessageHandler.DeleteCharacter(msgIn);
                break;

            //MapServer
            case MasterMessageType.ConnectionApproved:
                IncomingMessageHandler.ConnectionApproved(msgIn);
                break;

            //MapServer
            case MasterMessageType.MapCreated:
                IncomingMessageHandler.MapCreated(msgIn);
                break;

            //MapServer
            case MasterMessageType.MapsRemoved:
                IncomingMessageHandler.MapsRemoved(msgIn);
                break;

            case MasterMessageType.LoadReport:
                IncomingMessageHandler.LoadReport(msgIn);
                break;
            }
        }
コード例 #12
0
 public void SendMessageToConnectedPlayers(Account messageFrom, MasterMessageType messageType, string messageContent)
 {
     OutgoingMessageHandler.Instance.SendChatMessage(messageFrom, messageType, messageContent, OnlineCharacters);
 }
コード例 #13
0
 public void Write(MasterMessageType value)
 {
     Write((int)value);
 }
コード例 #14
0
 public void Write(MasterMessageType value)
 {
     Write((int)value);
 }