//Initialize the client
        public void helloMsgReceived(POIHelloMsg par, POITCPConnection connection)
        {
            //Notify data handler that authentication has been done
            //Proper CB functions are set here
            int userType = (int)par.UserType;
            int conType = (int)par.ConnType;
            string userName = par.UserName;

            //Handle the authentication

            POIWelcomeMsg.WelcomeStatus status = POIWelcomeMsg.WelcomeStatus.Failed;

            if (conType == POIMsgDefinition.POI_CONTROL_CHANNEL)
            {
                //Check if user already exists, create if not exists
                POIUser user;
                if (POIGlobalVar.UserProfiles.ContainsKey(userName))
                {
                    user = POIGlobalVar.UserProfiles[userName];
                }
                else
                {
                    user = new POIUser();
                    POIGlobalVar.UserProfiles[userName] = user;
                }

                //Initialize the user parameters
                user.UserID = userName;
                user.UserPrivilege = (POIUser.Privilege)userType;
                user.CtrlChannel = connection;

                if (user.Status == POIUser.ConnectionStatus.Disconnected)
                {
                    user.Status = POIUser.ConnectionStatus.Connected;
                }

                connection.Type = POIMsgParser.ParserType.Control;
                connection.Delegates = user;
                connection.AssociatedUser = user;

                try
                {
                    POIGlobalVar.SystemKernel.HandleUserJoin(user);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                status = POIWelcomeMsg.WelcomeStatus.CtrlChannelAuthenticated;
            }
            else if (conType == POIMsgDefinition.POI_DATA_CHANNEL)
            {
                if (POIGlobalVar.UserProfiles.ContainsKey(userName))
                {
                    POIUser user = POIGlobalVar.UserProfiles[userName];
                    if (user.Status == POIUser.ConnectionStatus.Connected)
                    {
                        user.DataChannel = connection;

                        connection.InitPayloadBufferForDataChannel();
                        connection.Type = POIMsgParser.ParserType.Data;
                        connection.Delegates = user;
                        connection.AssociatedUser = user;

                        status = POIWelcomeMsg.WelcomeStatus.DataChannelAuthenticated;
                    }
                }
            }

            //Send back the welcome message
            POIWelcomeMsg welcomeMsg = new POIWelcomeMsg(status);
            connection.SendData(welcomeMsg.getPacket());
        }
        private void parseHelloMsg(byte[] buffer, int offset)
        {
            POIHelloMsg msg = new POIHelloMsg();
            msg.deserialize(buffer, ref offset);

            Console.WriteLine(@"Hello");

            try
            {
                initClientMsgDelegate.helloMsgReceived(msg, this as POITCPConnection);
            }
            catch
            {
                Console.WriteLine("Error in calling hello msg callback!");
            }
        }