示例#1
0
 protected virtual void PrivateMessage(messageToUser msg)
 {
     if (this.isLoggedIn == false)
     {
         return;
     }
     this.send.sendMessageToIndividual(msg.reciever, msg.stringFormat);
 }
示例#2
0
 protected virtual void RevConnectToMe(messageToUser msg)
 {
     if (msg.sender != this.nick)
     {
         return;
     }
     this.send.sendMessageToIndividual(msg.reciever, msg.stringFormat + "|");
 }
示例#3
0
        protected virtual void Search(messageToUser msg)
        {
            if (this.isLoggedIn == false)
            {
                return;
            }

            if ((msg.sender.IndexOf(this.ipAddress, 0) == -1) || (msg.sender.IndexOf(this.nick, 0) == -1))
            {
                return;
            }
            //if (msg != this.nick)
            //	return;
            this.send.SendMessageToAll(msg.stringFormat);
        }
示例#4
0
        protected override void Search(messageToUser msg)
        {
            bool Handled = false;

            msg.allLocalUsers = this.ClientList;
            msg.allServers    = this.ServerList;

            foreach (GHub.plugin.aPlugIn plug in Plugins)
            {
                if (plug.PlugIn.Search(msg))
                {
                    Handled = true;
                }
            }
            if (!Handled)
            {
                base.Search(msg);
            }
        }
示例#5
0
 protected virtual void ConnectToMe(messageToUser msg)
 {
     this.send.sendMessageToIndividual(msg.reciever, msg.stringFormat + "|");
 }
示例#6
0
 protected virtual void GetInfo(messageToUser msg)
 {
     this.SendMessage(((GHub.client.user.User) this.ClientList.Get(msg.reciever)).rawUserInfo);
 }
示例#7
0
        // checks to see what message we are dealing with.
        // e.g. "$To" , "$Search" etc
        private Message DeterminMessage(string StartOfMessage, int firstSpacePosition, Message msg)
        {
            Message simpleMessage = new Message();

            string[]       splitMessage;
            serverUserInfo userInfo;

            GHub.client.userInfo usinfo;
            string nick;

            switch (StartOfMessage)
            {
            // another server is connecting to us and have sent
            // there username and pass.
            //
            //$LogginIn UserName Pass
            case "$LogginIn":

                splitMessage = msg.stringFormat.Split(' ');
                if (splitMessage.Length < 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }
                serverLogInInfo logIn = new serverLogInInfo();

                logIn.userName = splitMessage[1];
                logIn.pass     = splitMessage[2];

                logIn.type         = (int)ServerMessageTypes.LoggingIn;
                logIn.RawFormat    = msg.RawFormat;
                logIn.From         = (int)MessageFrom.Server;
                logIn.soc          = this.soc;
                logIn.stringFormat = msg.stringFormat;

                return(logIn);

            // we are telling this server that it has send a correct
            // user name and password.
            case "$loggedIn":

                simpleMessage.type         = (int)ServerMessageTypes.loggedIn;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;
                return(simpleMessage);

            case "$Badpass|":

                simpleMessage.type         = (int)ServerMessageTypes.BadLogIn;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;
                return(simpleMessage);

            // server is closing down
            case "$Exit":

                simpleMessage.type         = (int)ServerMessageTypes.Exit;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;
                return(simpleMessage);

            // another server is asking us for our username and pass
            // to be able to log into there server
            case "$Lock":

                simpleMessage.type         = (int)ServerMessageTypes.LogInInfoPlz;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;
                return(simpleMessage);

            // a new user has logged into another server and they are
            // telling us about it. the format of the user is as follows.
            //
            // $NewUser IsOP=<True/False> $MyINFO $ALL <nick> <interest>$ $<speed>$<e-mail>$<sharesize>$
            case "$NewUser":

                newUser NewUser = new newUser();

                userInfo = new serverUserInfo();

                nick = userInfo.parseNickFromMyInfo(msg.stringFormat.Substring(msg.stringFormat.IndexOf("$MyINFO")));
                if ((usinfo = GHub.client.Client.getnickInfo(nick)) != null)
                {
                    this.SendMessage("$Exit " + usinfo.nick + "|");
                    //this.closeAndRemoveUser();
                    recievedMessages.Clear();
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                // add the nick to the list of users held on another server
                userInfo.rawUserInfo = msg.stringFormat.Substring(msg.stringFormat.IndexOf("$MyINFO"));
                usersToServer.Add(userInfo);


                usinfo             = new userInfo(msg.soc, this.ServerList, this.ClientList, this.core);
                usinfo.rawUserInfo = userInfo.rawUserInfo;
                GHub.client.Client.AddToUserInfoList(usinfo);
                // add the new usersinfo string to the main array list that holds all the myINFO's
//					GHub.client.Client.AddToUserInfoList(  usinfo  );

                NewUser.type         = (int)ServerMessageTypes.NewUser;
                NewUser.RawFormat    = msg.RawFormat;
                NewUser.From         = (int)MessageFrom.Server;
                NewUser.soc          = this.soc;
                NewUser.stringFormat = msg.stringFormat;

                NewUser.slots       = userInfo.slots;
                NewUser.normHubs    = userInfo.normHubs;
                NewUser.regHubs     = userInfo.regHubs;
                NewUser.opHubs      = userInfo.opHubs;
                NewUser.description = userInfo.description;
                NewUser.email       = userInfo.eMail;
                NewUser.nick        = userInfo.nick;
                return(NewUser);

            // the server is sending us a users MyINFO that exists
            // there end.
            case "$MyINFO":

                // myINFO string done incorectly so ignore it.
                if (msg.stringFormat.Length < 9)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                userInfo = new serverUserInfo();


                nick = userInfo.parseNickFromMyInfo(msg.stringFormat);
                // if this the the time were 2 servers are connecting to each other
                // there should be a chance bother servers could have the same nick logged
                // into there server. We can not let this happen.  If this does happen
                // we will inform the other server we are droping the connection and let them
                // know why

/*
 *                                      if (   (usinfo = GHub.client.Client.getnickInfo(nick)) != null)
 *                                      {
 *                                              this.SendMessage("$Exit " + usinfo.nick + "|");
 *                                              //this.closeAndRemoveUser();
 *                                              recievedMessages.Clear();
 *                                              simpleMessage.type = -1;
 *                                              return simpleMessage;
 *                                      }*/
                usinfo             = GHub.client.Client.getnickInfo(nick);
                usinfo.rawUserInfo = msg.stringFormat;

                userInfo             = usersToServer.Get(nick);
                userInfo.rawUserInfo = msg.stringFormat;

                GHub.client.Client.upDateInfoList();

                myInfo info = new myInfo();


                info.type         = (int)Messagetype.MyINFO;
                info.RawFormat    = msg.RawFormat;
                info.From         = (int)MessageFrom.Server;
                info.soc          = this.soc;
                info.stringFormat = msg.stringFormat;

                info.slots       = userInfo.slots;
                info.normHubs    = userInfo.normHubs;
                info.regHubs     = userInfo.regHubs;
                info.opHubs      = userInfo.opHubs;
                info.description = userInfo.description;
                info.email       = userInfo.eMail;
                info.nick        = userInfo.nick;

                return(info);

/*
 *                                      // the user does not exist in the array list so add it
 *                                      if (userInfo == null)
 *                                      {
 *                                              userInfo = new serverUserInfo();
 *                                              userInfo.rawUserInfo = msg.stringFormat;
 *                                              usersToServer.Add(userInfo);
 *
 *                                              info.type =(int)Messagetype.MyINFO;
 *                                              info.RawFormat = msg.RawFormat;
 *                                              info.From = (int)MessageFrom.Server;
 *                                              info.soc = this.soc;
 *                                              info.stringFormat = msg.stringFormat;
 *
 *                                              info.slots = userInfo.slots;
 *                                              info.normHubs = userInfo.normHubs;
 *                                              info.regHubs = userInfo.regHubs;
 *                                              info.opHubs = userInfo.opHubs;
 *                                              info.description = userInfo.description;
 *                                              info.email = userInfo.eMail;
 *                                              info.nick = userInfo.nick;
 *
 *                                              usinfo = new userInfo(msg.soc,this.ServerList,this.ClientList);
 *                                              usinfo.rawUserInfo = msg.stringFormat;
 *                                              // add the new usersinfo string to the main array list that holds all the myINFO's
 *                                              GHub.client.Client.AddToUserInfoList(  usinfo  );
 *
 *                                              return info;
 *                                      }*/
/*
 *                                      // update the users info with there new myINFO string.
 *                                      userInfo.rawUserInfo = msg.stringFormat;
 *
 *                                      usinfo = GHub.client.Client.getnickInfo(userInfo.nick);
 *                                      usinfo.rawUserInfo = userInfo.rawUserInfo;
 *                                      GHub.client.Client.upDateInfoList();
 *
 *
 *                                      info.type =(int)Messagetype.MyINFO;
 *                                      info.RawFormat = msg.RawFormat;
 *                                      info.From = (int)MessageFrom.Server;
 *                                      info.soc = this.soc;
 *                                      info.stringFormat = msg.stringFormat;
 *
 *                                      info.slots = userInfo.slots;
 *                                      info.normHubs = userInfo.normHubs;
 *                                      info.regHubs = userInfo.regHubs;
 *                                      info.opHubs = userInfo.opHubs;
 *                                      info.description = userInfo.description;
 *                                      info.email = userInfo.eMail;
 *                                      info.nick = userInfo.nick;
 *
 *                                      return info;*/


            // this will only be sent during server to server log in.
            // We will find out about any new user that connects after that
            // through $NewUser
            case "$OpList":

                // OpList string done incorectly so ignore it.
                if (msg.stringFormat.Length < 9)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)ServerMessageTypes.OPList;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;
                return(simpleMessage);

            // a server is asking for our users list
            // this will happen at the log in process.
            case "$AllUserInfo":

                simpleMessage.type         = (int)ServerMessageTypes.AllUsersInfo;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;
                return(simpleMessage);

            // a user is leaving on another server
            case "$Quit":

                // Quit string done incorectly so ignore it.
                if (msg.stringFormat.Length < 7)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)ServerMessageTypes.UserLeft;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Server;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                return(simpleMessage);

            // a user on another server is atempting to chat to a user
            // on our server.
            case "$To:":

                splitMessage = msg.stringFormat.Split('$');
                string[] FirstPartOfSplit;

                // not enough parameters in the string for it to be right
                if (splitMessage.Length < 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                FirstPartOfSplit = splitMessage[1].Split(' ');

                // not enough parameters in the string for it to be right
                if (FirstPartOfSplit.Length < 5)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                messageToUser PrivateMessage = new messageToUser();

                PrivateMessage.type      = (int)Messagetype.ChatPM;
                PrivateMessage.RawFormat = msg.RawFormat;
                PrivateMessage.From      = (int)MessageFrom.Client;
                PrivateMessage.soc       = this.soc;

                PrivateMessage.sender            = FirstPartOfSplit[3];
                PrivateMessage.reciever          = FirstPartOfSplit[1];
                PrivateMessage.messageToReciever = splitMessage[2];
                PrivateMessage.stringFormat      = msg.stringFormat;

                return(PrivateMessage);

            // a user on another server is searching for somthing
            // this message must be relayed to all the clients on this
            // server.
            case "$Search":

                splitMessage = msg.stringFormat.Split(' ');
                if (splitMessage.Length < 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                messageToUser Search = new messageToUser();
                Search.sender = splitMessage[1];

                Search.type         = (int)Messagetype.Search;
                Search.RawFormat    = msg.RawFormat;
                Search.From         = (int)MessageFrom.Client;
                Search.soc          = this.soc;
                Search.stringFormat = msg.stringFormat;

                return(simpleMessage);

            default:

                if (StartOfMessage.StartsWith("$"))
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                mainChat MainChatMessage = new mainChat();

                MainChatMessage.type         = (int)Messagetype.MainChatMessage;
                MainChatMessage.RawFormat    = msg.RawFormat;
                MainChatMessage.From         = (int)MessageFrom.Client;
                MainChatMessage.soc          = this.soc;
                MainChatMessage.stringFormat = msg.stringFormat;

                return(MainChatMessage);
            }
        }
示例#8
0
        // checks to see what message we are dealing with.
        // e.g. "$To" , "$Search" etc
        private Message DeterminMessage(string StartOfMessage, int firstSpacePosition, Message msg)
        {
            Message simpleMessage = new Message();

            string[] splitMessage;

            switch (StartOfMessage)
            {
            case "$Supports":

                // Supports string done incorectly so ignore it.
                if (msg.stringFormat.Length < 11)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                splitMessage = msg.stringFormat.Substring(firstSpacePosition + 1).Split(' ');

                supports Support = new supports();
                Support.supporList = new string[splitMessage.Length - 1];
                for (int iCount = 0; iCount < splitMessage.Length - 1; iCount++)
                {
                    Support.supporList[iCount] = splitMessage[iCount];
                }

                Support.type         = (int)Messagetype.Supports;
                Support.RawFormat    = msg.RawFormat;
                Support.From         = (int)MessageFrom.Client;
                Support.soc          = this.soc;
                Support.stringFormat = msg.stringFormat;

                simpleMessage = null;
                splitMessage  = null;
                return(Support);

            case "$Key":

                // Key string done incorectly so ignore it.
                if (msg.stringFormat.Length < 6)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)Messagetype.Key;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            case "$ValidateNick":

                // ValidateNick string done incorectly so ignore it.
                if (msg.stringFormat.Length < 15)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)Messagetype.ValidateNick;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            case "$GetNickList":

                simpleMessage.type         = (int)Messagetype.GetNickList;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            case "$GetINFO":

                splitMessage = msg.stringFormat.Split(' ');
                if (splitMessage.Length < 3)
                {
                    simpleMessage.type         = -1;
                    simpleMessage.RawFormat    = msg.RawFormat;
                    simpleMessage.From         = (int)MessageFrom.Client;
                    simpleMessage.soc          = this.soc;
                    simpleMessage.stringFormat = msg.stringFormat;

                    splitMessage = null;
                    return(simpleMessage);
                }

                messageToUser getInfo = new messageToUser();

                getInfo.type         = (int)Messagetype.GetINFO;
                getInfo.RawFormat    = msg.RawFormat;
                getInfo.From         = (int)MessageFrom.Client;
                getInfo.soc          = this.soc;
                getInfo.stringFormat = msg.stringFormat;
                getInfo.sender       = splitMessage[2];
                getInfo.reciever     = splitMessage[1];

                splitMessage  = null;
                simpleMessage = null;
                return(getInfo);

            case "$MyPass":


                // MyPass string done incorectly so ignore it.
                if (msg.stringFormat.Length < 9)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)Messagetype.MyPass;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            case "$Version":

                // Version string done incorectly so ignore it.
                if (msg.stringFormat.Length < 10)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)Messagetype.Version;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            // a client is sending us a users MyINFO list
            case "$MyINFO":

                // myINFO string done incorectly so ignore it.
                if (msg.stringFormat.Length < 9)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                myInfo myINFO = new myInfo();
                myINFO.nick = this.nick;
                // convert the myinfo string to something
                // readable
                this.rawUserInfo = msg.stringFormat;

                // if the user has tried to change there nick while logged in.
                if (myINFO.nick != this.nick)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    myINFO             = null;
                    return(simpleMessage);
                }

                myINFO.type         = (int)Messagetype.MyINFO;
                myINFO.RawFormat    = msg.RawFormat;
                myINFO.From         = (int)MessageFrom.Client;
                myINFO.soc          = this.soc;
                myINFO.stringFormat = msg.stringFormat;

                myINFO.slots       = this.slots;
                myINFO.normHubs    = this.normHubs;
                myINFO.regHubs     = this.regHubs;
                myINFO.opHubs      = this.opHubs;
                myINFO.description = this.description;
                myINFO.email       = this.eMail;
                myINFO.nick        = this.nick;

                splitMessage  = null;
                simpleMessage = null;

                return(myINFO);

            // a user is leaving on another server
            case "$Quit":

                // Quit string done incorectly so ignore it.
                if (msg.stringFormat.Length < 7)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)Messagetype.QUIT;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                closeAndRemoveUser();
                splitMessage = null;
                return(simpleMessage);

            // a user on another server is atempting to chat to a user
            // on our server.
            case "$To:":

                splitMessage = msg.stringFormat.Split('$');
                string[] FirstPartOfSplit;

                // not enough parameters in the string for it to be right
                if (splitMessage.Length < 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;

                    splitMessage     = null;
                    FirstPartOfSplit = null;
                    return(simpleMessage);
                }

                FirstPartOfSplit = splitMessage[1].Split(' ');

                // not enough parameters in the string for it to be right
                if (FirstPartOfSplit.Length < 5)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;

                    splitMessage     = null;
                    FirstPartOfSplit = null;
                    return(simpleMessage);
                }

                // user trying to send a pm to some one using a nick other
                // than there own.
                if (FirstPartOfSplit[3] != this.nick)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;

                    splitMessage     = null;
                    FirstPartOfSplit = null;
                    return(simpleMessage);
                }

                messageToUser PrivateMessage = new messageToUser();

                PrivateMessage.type      = (int)Messagetype.ChatPM;
                PrivateMessage.RawFormat = msg.RawFormat;
                PrivateMessage.From      = (int)MessageFrom.Client;
                PrivateMessage.soc       = this.soc;

                PrivateMessage.sender            = FirstPartOfSplit[3];
                PrivateMessage.reciever          = FirstPartOfSplit[1];
                PrivateMessage.messageToReciever = splitMessage[2];
                PrivateMessage.stringFormat      = msg.stringFormat;

                splitMessage     = null;
                FirstPartOfSplit = null;
                simpleMessage    = null;
                return(PrivateMessage);

            // a user on another server is searching for somthing
            // this message must be relayed to all the clients on this
            // server.

            case "$Kick":

                if (msg.stringFormat.Length < 7)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                simpleMessage.type         = (int)Messagetype.Kick;
                simpleMessage.RawFormat    = msg.RawFormat;
                simpleMessage.From         = (int)MessageFrom.Client;
                simpleMessage.soc          = this.soc;
                simpleMessage.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            case "$Search":


                splitMessage = msg.stringFormat.Split(' ');
                if (splitMessage.Length < 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                messageToUser Search = new messageToUser();
                Search.sender = splitMessage[1];

                Search.type         = (int)Messagetype.Search;
                Search.RawFormat    = msg.RawFormat;
                Search.From         = (int)MessageFrom.Client;
                Search.soc          = this.soc;
                Search.stringFormat = msg.stringFormat;

                splitMessage = null;
                return(simpleMessage);

            case "$ConnectToMe":
                //$ConnectToMe <remoteNick> <senderIp>:<senderPort>
                splitMessage = msg.stringFormat.Split(' ');

                if (splitMessage.Length != 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                messageToUser connectToMe = new messageToUser();

                connectToMe.sender   = this.nick;
                connectToMe.reciever = splitMessage[1];

                connectToMe.type         = (int)Messagetype.ConnectToMe;
                connectToMe.RawFormat    = msg.RawFormat;
                connectToMe.From         = (int)MessageFrom.Client;
                connectToMe.soc          = this.soc;
                connectToMe.stringFormat = msg.stringFormat;

                splitMessage  = null;
                simpleMessage = null;
                return(connectToMe);

            case "$RevConnectToMe":
                //$RevConnectToMe <nick> <remoteNick>
                splitMessage = msg.stringFormat.Split(' ');

                if (splitMessage.Length != 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }
                messageToUser ReConnectToMe = new messageToUser();

                ReConnectToMe.sender   = splitMessage[1];
                ReConnectToMe.reciever = splitMessage[2];

                ReConnectToMe.type         = (int)Messagetype.RevConnectToMe;
                ReConnectToMe.RawFormat    = msg.RawFormat;
                ReConnectToMe.From         = (int)MessageFrom.Client;
                ReConnectToMe.soc          = this.soc;
                ReConnectToMe.stringFormat = msg.stringFormat;

                splitMessage  = null;
                simpleMessage = null;
                return(ReConnectToMe);

            default:

                if (StartOfMessage.StartsWith("$"))
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;
                    splitMessage       = null;
                    return(simpleMessage);
                }

                mainChat MainChatMessage = new mainChat();

                MainChatMessage.type         = (int)Messagetype.MainChatMessage;
                MainChatMessage.RawFormat    = msg.RawFormat;
                MainChatMessage.From         = (int)MessageFrom.Client;
                MainChatMessage.soc          = this.soc;
                MainChatMessage.stringFormat = msg.stringFormat;
                MainChatMessage.sender       = this.nick;

                if (msg.stringFormat.Length < this.nick.Length + 3)
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;

                    splitMessage    = null;
                    MainChatMessage = null;
                    return(simpleMessage);
                }
                // if the message does not contain <nick>
                if (MainChatMessage.stringFormat.Substring(0, 3 + this.nick.Length) != "<" + this.nick + "> ")
                {
                    // -1 indicates we are just going to ignore this message
                    simpleMessage.type = -1;

                    splitMessage    = null;
                    MainChatMessage = null;
                    return(simpleMessage);
                }

                splitMessage  = null;
                simpleMessage = null;
                return(MainChatMessage);
            }
        }
示例#9
0
 public bool Search(messageToUser msg)
 {
     return(false);
 }
示例#10
0
 public bool PrivateMessage(messageToUser msg)
 {
     return(false);
 }