Example #1
0
        public void execute_기존에_입력된_정보가_존재하고_파라미터는_Null인_경우__Exception발생시키는지()
        {
            MockRepository            mocks         = new MockRepository();
            ICommandListener          listener      = mocks.DynamicMock <myInfoController>();
            myInfo                    myInfo        = null;
            MyInfoInsertUpdateCommand myInfoCommand = new MyInfoInsertUpdateCommand(myInfo, listener);

            myInfoCommand.execute();
        }
Example #2
0
        public void Insert_Test_True를반환하는지()
        {
            //Arrange
            MockRepository mock = new MockRepository();
            myInfo         mi   = mock.Stub <myInfo>();
            //Act
            bool isOK = MyInfoController.Insert(mi);

            Assert.IsTrue(isOK);
        }
Example #3
0
        public void Undo_Test_기존에_입력된_내용이_없을때()
        {
            MockRepository            mocks    = new MockRepository();
            ICommandListener          listener = mocks.DynamicMock <myInfoController>();
            myInfo                    mi       = mocks.Stub <myInfo>();
            MyInfoInsertUpdateCommand myIUCMD  = new MyInfoInsertUpdateCommand(mi, listener);

            myIUCMD.preMyInfo = null;
            using (mocks.Record())
            {
                listener.Delete(mi);
            }
            myIUCMD.Undo();
            mocks.Verify(listener);
        }
Example #4
0
        public void execute_기존에_입력된_정보가_하나도_없고_파라미터는_정상인_경우()
        {
            MockRepository            mocks         = new MockRepository();
            ICommandListener          listener      = mocks.DynamicMock <myInfoController>();
            myInfo                    myInfo        = mocks.Stub <myInfo>();
            MyInfoInsertUpdateCommand myInfoCommand = new MyInfoInsertUpdateCommand(myInfo, listener);

            using (mocks.Record())
            {
                myInfoCommand.preMyInfo = null;
                listener.Insert(myInfo);
                LastCall.Return(true);
            }
            myInfoCommand.execute();
            mocks.Verify(listener);
        }
Example #5
0
        protected override void myInfo(myInfo msg)
        {
            bool Handled = false;

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

            foreach (GHub.plugin.aPlugIn plug in Plugins)
            {
                if (plug.PlugIn.myInfo(msg))
                {
                    Handled = true;
                }
            }
            if (!Handled)
            {
                base.myInfo(msg);
            }
        }
Example #6
0
        // user has send eather there first myInfo or
        // is just sending another to update there
        // nick, share size, description etc.
        protected virtual void myInfo(myInfo msg)
        {
            // not really much to do. the myInfo string has
            // allready been updated in the ClientWorkOutMessage.

            // now just need to let the other users know that a user
            // has changed there myInfo string.

            if (!this.loggedInCorrectly)
            {
                this.closeAndRemoveUser("Incorect log in|");
                return;
            }


            // Ok this is very important. we are saying, if the user has not logged in
            // this will be there first myINFO string they are sending.
            // this means it does not edist in the myINFO array held in the Client class.
            // Because of this we need to add it to the array. Simple enough so far.
            // however the user is allowed to send myINFO as many times as he likes
            // during his connection to the hub.  When this happens the myINFO string
            // will be updated.  Now if im right when its update it will also update
            // the one that was added to the user info array because i am hoping
            // it is just a pointer that is tored in the user info array (don't see
            // what else it could be).
            if (!this.isLoggedIn)
            {
                this.isLoggedIn = true;
                GHub.client.Client.AddToUserInfoList((GHub.client.userInfo) this);
                LoggedIn();
            }
            else
            {
                // user has changed there myINFO string so we need to update it in the
                // InfoList.
                GHub.client.Client.upDateInfoList();
            }


            this.send.SendMessageToAll(this.rawUserInfo + "|");
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #9
0
 public bool myInfo(myInfo msg)
 {
     return(false);
 }
Example #10
0
    void Combine()
    {
        //this is to combine objects with tags
        if (Input.GetKeyDown(KeyCode.Space))
        {
            objectInfo       = MyObjects[0].GetComponent <myInfo>(); //the label of the object we're referring to a lot here on out
            secondObjectInfo = MyObjects[1].GetComponent <myInfo>(); //the second thing you picked up

            switch (taskNum)
            {
            case 1: {
                //find clean and dirty
                if (checkMatchingTags("clean", "dirty") && MyObjects.Count <= 2)
                {
                    //success
                    Debug.Log("YOU COMBINED CORRECTLY");
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Puzzle 1 Solve Time (sec)", (puzzle1Timer / 60).ToString());
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Wrong Combination Attempts To Puzzle 1", numWrongCombos.ToString());
                    numWrongCombos = 0;
                    puzzle1Timer   = 0;
                    //Remove old objects for new one
                    Vector3    pos  = MyObjects[0].transform.position;                                                                  //standardize this to be a uniform location infront of camera
                    GameObject temp = Instantiate(puzzle1_result, transform.position + (transform.forward * 1.5f), transform.rotation); //move this to infront of camera
                    temp.GetComponent <myInfo>().label = "Tidies";
                    temp.name = "SlimyCucumber";
                    temp.GetComponent <myInfo>().sallyObject = true;

                    //sound
                    //testAudio1.clip = comboSuccess;
                    //testAudio1.Play();
                    //testAudio2.clip = combo1;
                    //testAudio2.Play();

                    //newAudio
                    AudioManager.instance.PlaySound(AudioManager.instance.createUndies, gameObject);

                    //particles
                    presentGet.transform.position = temp.transform.position;
                    //presentGet.transform.parent = this.gameObject.transform;
                    presentGet.Play();
                    presentGet2.transform.position = temp.transform.position;
                    // presentGet2.transform.parent = this.gameObject.transform;
                    presentGet2.Play();
                    presentGet3.transform.position = temp.transform.position;
                    //presentGet3.transform.parent = this.gameObject.transform;
                    presentGet3.Play();
                    presentGet4.transform.position = temp.transform.position;
                    // presentGet4.transform.parent = this.gameObject.transform;
                    presentGet4.Play();
                    temp.GetComponent <myInfo>().partiStart = true;

                    detachItems();
                    cleanCam();
                    temp.GetComponent <Rigidbody>().useGravity = false;
                    //temp.GetComponent<Rigidbody>().isKinematic = false;
                    temp.GetComponent <Rigidbody>().freezeRotation = true;
                    temp.GetComponent <Rigidbody>().angularDrag    = 0f;
                    temp.GetComponent <Rigidbody>().mass           = 1f;
                    //Show the item's label on the present's tag
                    Debug.Log(temp.transform.GetChild(0).name);
                    Debug.Log(temp.transform.GetChild(0).transform.GetChild(0).name);
                    TextMeshProUGUI tmpro = temp.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>();       //sorry this is because it defaults the text like three children down :(
                    tmpro.SetText(temp.name);

                    //Debug.Log(MyObjects.Count);
                }

                else
                {
                    ComboFailed();
                }

                break;
            }

            case 2: {
                //find shocking and evil
                ///////////////////////////////////
                //NOT USED IN GAME AUDIO VERSION///
                ///////////////////////////////////

                if (checkMatchingTags("shocking", "evil") && MyObjects.Count <= 2)
                {
                    //success
                    Debug.Log("YOU COMBINED CORRECTLY");
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Puzzle 2 Solve Time (sec)", (puzzle1Timer / 60).ToString());
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Wrong Combination Attempts To Puzzle 2", numWrongCombos.ToString());
                    numWrongCombos = 0;
                    puzzle1Timer   = 0;
                    //Remove old objects for new one
                    Vector3    pos  = MyObjects[0].transform.position;
                    GameObject temp = Instantiate(puzzle2_result, transform.position + (transform.forward * 1.5f), transform.rotation);        //move this to infront of camera
                    temp.GetComponent <Rigidbody>().freezeRotation = false;
                    temp.transform.Rotate(-90, 0, 0);
                    temp.GetComponent <myInfo>().label = "Death by Neon";
                    temp.name = "GlowingScythe";
                    temp.GetComponent <myInfo>().sallyObject = true;

                    //sound
                    testAudio1.clip = comboSuccess;
                    testAudio1.Play();
                    testAudio2.clip = combo2;
                    testAudio2.Play();

                    //particles
                    presentGet.transform.position = temp.transform.position;
                    //presentGet.transform.parent = this.gameObject.transform;
                    presentGet.Play();
                    presentGet2.transform.position = temp.transform.position;
                    // presentGet2.transform.parent = this.gameObject.transform;
                    presentGet2.Play();
                    presentGet3.transform.position = temp.transform.position;
                    //presentGet3.transform.parent = this.gameObject.transform;
                    presentGet3.Play();
                    presentGet4.transform.position = temp.transform.position;
                    // presentGet4.transform.parent = this.gameObject.transform;
                    presentGet4.Play();
                    temp.GetComponent <myInfo>().partiStart = true;

                    detachItems();
                    cleanCam();
                    temp.GetComponent <Rigidbody>().useGravity = false;
                    // temp.GetComponent<Rigidbody>().isKinematic = false;
                    temp.GetComponent <Rigidbody>().freezeRotation = true;
                    temp.GetComponent <Rigidbody>().angularDrag    = 0f;
                    temp.GetComponent <Rigidbody>().mass           = 1f;

                    //Show the item's label on the present's tag
                    Debug.Log(temp.transform.GetChild(0).name);
                    Debug.Log(temp.transform.GetChild(0).transform.GetChild(0).name);
                    TextMeshProUGUI tmpro = temp.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>();       //sorry this is because it defaults the text like three children down :(
                    tmpro.SetText(temp.name);
                }

                else
                {
                    ComboFailed();
                }

                break;
            }

            case 3: {
                //find comedic and dramatic
                if (checkMatchingTags("hot", "risky") && MyObjects.Count <= 2)
                {
                    //success
                    Debug.Log("YOU COMBINED CORRECTLY");
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Puzzle 3 Solve Time (sec)", (puzzle1Timer / 60).ToString());
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Wrong Combination Attempts To Puzzle 3", numWrongCombos.ToString());
                    numWrongCombos = 0;
                    puzzle1Timer   = 0;
                    //Remove old objects for new one
                    Vector3    pos  = MyObjects[0].transform.position;
                    GameObject temp = Instantiate(puzzle3_result, transform.position + (transform.forward * 1.5f), transform.rotation);        //move this to infront of camera
                    temp.GetComponent <Rigidbody>().freezeRotation = false;
                    temp.transform.Rotate(-90, 0, 0);
                    temp.GetComponent <myInfo>().label = "Inevitable Spicy Poops";
                    temp.name = "SpicyPoops";
                    temp.GetComponent <myInfo>().sallyObject = true;

                    //sound
                    //testAudio1.clip = comboSuccess;
                    //testAudio1.Play();
                    //testAudio2.clip = combo3;
                    //testAudio2.Play();

                    //newAudio
                    AudioManager.instance.PlaySound(AudioManager.instance.createSpicy, gameObject);


                    //particles
                    presentGet.transform.position = temp.transform.position;
                    //presentGet.transform.parent = this.gameObject.transform;
                    presentGet.Play();
                    presentGet2.transform.position = temp.transform.position;
                    // presentGet2.transform.parent = this.gameObject.transform;
                    presentGet2.Play();
                    presentGet3.transform.position = temp.transform.position;
                    //presentGet3.transform.parent = this.gameObject.transform;
                    presentGet3.Play();
                    presentGet4.transform.position = temp.transform.position;
                    // presentGet4.transform.parent = this.gameObject.transform;
                    presentGet4.Play();
                    temp.GetComponent <myInfo>().partiStart = true;

                    detachItems();
                    cleanCam();
                    temp.GetComponent <Rigidbody>().useGravity = false;
                    // temp.GetComponent<Rigidbody>().isKinematic = false;
                    temp.GetComponent <Rigidbody>().freezeRotation = true;
                    temp.GetComponent <Rigidbody>().angularDrag    = 0f;
                    temp.GetComponent <Rigidbody>().mass           = 1f;

                    //Show the item's label on the present's tag
                    Debug.Log(temp.transform.GetChild(0).name);
                    Debug.Log(temp.transform.GetChild(0).transform.GetChild(0).name);
                    TextMeshProUGUI tmpro = temp.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>();       //sorry this is because it defaults the text like three children down :(
                    tmpro.SetText(temp.name);
                }

                else
                {
                    ComboFailed();
                }

                break;
            }

            case 4:
            {
                //find comedic and dramatic
                ////////////////////////////////////
                ///NOT USED IN GAME AUDIO VERSION///
                ////////////////////////////////////

                if (checkMatchingTags("basic", "acidic") && MyObjects.Count <= 2)
                {
                    //success
                    Debug.Log("YOU COMBINED CORRECTLY");
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Puzzle 4 Solve Time (sec)", (puzzle1Timer / 60).ToString());
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Wrong Combination Attempts To Puzzle 4", numWrongCombos.ToString());
                    numWrongCombos = 0;
                    puzzle1Timer   = 0;
                    //Remove old objects for new one
                    Vector3    pos  = MyObjects[0].transform.position;
                    GameObject temp = Instantiate(puzzle4_result, transform.position + (transform.forward * 1.5f), transform.rotation);        //move this to infront of camera
                    temp.GetComponent <myInfo>().label = "Margarita";
                    temp.name = "Margarita";
                    temp.GetComponent <myInfo>().sallyObject = true;

                    //sound
                    testAudio1.clip = comboSuccess;
                    testAudio1.Play();
                    testAudio2.clip = combo4;
                    testAudio2.Play();

                    //particles
                    presentGet.transform.position = temp.transform.position;
                    //presentGet.transform.parent = this.gameObject.transform;
                    presentGet.Play();
                    presentGet2.transform.position = temp.transform.position;
                    // presentGet2.transform.parent = this.gameObject.transform;
                    presentGet2.Play();
                    presentGet3.transform.position = temp.transform.position;
                    //presentGet3.transform.parent = this.gameObject.transform;
                    presentGet3.Play();
                    presentGet4.transform.position = temp.transform.position;
                    // presentGet4.transform.parent = this.gameObject.transform;
                    presentGet4.Play();
                    temp.GetComponent <myInfo>().partiStart = true;

                    detachItems();
                    cleanCam();
                    temp.GetComponent <Rigidbody>().useGravity = false;
                    // temp.GetComponent<Rigidbody>().isKinematic = false;
                    temp.GetComponent <Rigidbody>().freezeRotation = true;
                    temp.GetComponent <Rigidbody>().angularDrag    = 0f;
                    temp.GetComponent <Rigidbody>().mass           = 1f;

                    //Show the item's label on the present's tag
                    Debug.Log(temp.transform.GetChild(0).name);
                    Debug.Log(temp.transform.GetChild(0).transform.GetChild(0).name);
                    TextMeshProUGUI tmpro = temp.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>();       //sorry this is because it defaults the text like three children down :(
                    tmpro.SetText(temp.name);
                }

                else
                {
                    ComboFailed();
                }

                break;
            }

            case 5:
            {
                //find tasty and explosive
                if (checkMatchingTags("tasty", "explosive") && MyObjects.Count <= 2)
                {
                    //success
                    Debug.Log("YOU COMBINED CORRECTLY");
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Puzzle 5 Solve Time (sec)", (puzzle1Timer / 60).ToString());
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Wrong Combination Attempts To Puzzle 5", numWrongCombos.ToString());
                    numWrongCombos = 0;
                    puzzle1Timer   = 0;
                    //Remove old objects for new one
                    Vector3    pos  = MyObjects[0].transform.position;
                    GameObject temp = Instantiate(puzzle5_result, transform.position + (transform.forward * 1.5f), transform.rotation);            //move this to infront of camera

                    //sound
                    //testAudio1.clip = comboSuccess;
                    //testAudio1.Play();
                    //testAudio2.clip = combo5;
                    //testAudio2.Play();

                    //newAudio
                    AudioManager.instance.PlaySound(AudioManager.instance.createPopcorn, gameObject);

                    //particles
                    presentGet.transform.position = temp.transform.position;
                    //presentGet.transform.parent = this.gameObject.transform;
                    presentGet.Play();
                    presentGet2.transform.position = temp.transform.position;
                    // presentGet2.transform.parent = this.gameObject.transform;
                    presentGet2.Play();
                    presentGet3.transform.position = temp.transform.position;
                    //presentGet3.transform.parent = this.gameObject.transform;
                    presentGet3.Play();
                    presentGet4.transform.position = temp.transform.position;
                    // presentGet4.transform.parent = this.gameObject.transform;
                    presentGet4.Play();
                    temp.GetComponent <myInfo>().partiStart = true;

                    temp.GetComponent <myInfo>().label = "Popcorn";
                    temp.name = "Popcorn";
                    temp.GetComponent <myInfo>().sallyObject = false;

                    //open the door


                    detachItems();
                    cleanCam();
                    temp.GetComponent <Rigidbody>().useGravity = false;
                    //temp.GetComponent<Rigidbody>().isKinematic = false;
                    temp.GetComponent <Rigidbody>().freezeRotation = true;
                    temp.GetComponent <Rigidbody>().angularDrag    = 0f;
                    temp.GetComponent <Rigidbody>().mass           = 1f;

                    //Show the item's label on the present's tag
                    Debug.Log(temp.transform.GetChild(0).name);
                    Debug.Log(temp.transform.GetChild(0).transform.GetChild(0).name);
                    TextMeshProUGUI tmpro = temp.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>();       //sorry this is because it defaults the text like three children down :(
                    tmpro.SetText(temp.name);
                }

                else
                {
                    ComboFailed();
                }

                break;
            }

            case 6:
            {
                //find comedic and dramatic
                if (checkMatchingTags("funky", "medicinal") && MyObjects.Count <= 2)
                {
                    //success
                    Debug.Log("YOU COMBINED CORRECTLY");
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Puzzle 6 Solve Time (sec)", (puzzle1Timer / 60).ToString());
                    //Tinylytics.AnalyticsManager.LogCustomMetric("Wrong Combination Attempts To Puzzle 6", numWrongCombos.ToString());
                    numWrongCombos = 0;
                    puzzle1Timer   = 0;
                    //Remove old objects for new one
                    Vector3    pos  = MyObjects[0].transform.position;
                    GameObject temp = Instantiate(puzzle6_result, transform.position + (transform.forward * 1.5f), transform.rotation);        //move this to infront of camera
                    temp.GetComponent <myInfo>().label = "Boogie RX";
                    temp.name = "DiscoPills";
                    temp.GetComponent <myInfo>().sallyObject = true;

                    //sound
                    //testAudio1.clip = comboSuccess;
                    //testAudio1.Play();
                    //testAudio2.clip = combo6;
                    //testAudio2.Play();

                    //newAudio
                    AudioManager.instance.PlaySound(AudioManager.instance.createMedicine, gameObject);


                    //particles
                    presentGet.transform.position = temp.transform.position;
                    //presentGet.transform.parent = this.gameObject.transform;
                    presentGet.Play();
                    presentGet2.transform.position = temp.transform.position;
                    // presentGet2.transform.parent = this.gameObject.transform;
                    presentGet2.Play();
                    presentGet3.transform.position = temp.transform.position;
                    //presentGet3.transform.parent = this.gameObject.transform;
                    presentGet3.Play();
                    presentGet4.transform.position = temp.transform.position;
                    // presentGet4.transform.parent = this.gameObject.transform;
                    presentGet4.Play();
                    temp.GetComponent <myInfo>().partiStart = true;

                    detachItems();
                    cleanCam();
                    temp.GetComponent <Rigidbody>().useGravity = false;
                    // temp.GetComponent<Rigidbody>().isKinematic = false;
                    temp.GetComponent <Rigidbody>().freezeRotation = true;
                    temp.GetComponent <Rigidbody>().angularDrag    = 0f;
                    temp.GetComponent <Rigidbody>().mass           = 1f;

                    //Show the item's label on the present's tag
                    Debug.Log(temp.transform.GetChild(0).name);
                    Debug.Log(temp.transform.GetChild(0).transform.GetChild(0).name);
                    TextMeshProUGUI tmpro = temp.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>();       //sorry this is because it defaults the text like three children down :(
                    tmpro.SetText(temp.name);
                }

                else
                {
                    ComboFailed();
                }

                break;
            }
            }
        }
    }
Example #11
0
 protected virtual void myINFO(myInfo msg)
 {
     this.send.SendMessageToAllLocalUsers(msg.stringFormat);
 }