Avalon.Network.Client.Channel.ChannelSelect C# (CSharp) Method

ChannelSelect() public static method

public static ChannelSelect ( byte packet, SocketClient sockstate ) : void
packet byte
sockstate SocketClient
return void
        public static void ChannelSelect(byte[] packet, SocketClient sockstate)
        {
            CMSG_CHANNEL_SELECT cpkt = (CMSG_CHANNEL_SELECT)packet;
            String SqrName = cpkt.SqrName;

            lock (Program.SquareList)
            {
                for (int i = 0; i < Program.SquareList.Count; ++i)
                {
                    if (Program.SquareList[i].Name == SqrName)
                    {
                        SMSG_CHANNEL_SELECT spkt = new SMSG_CHANNEL_SELECT(Program.SquareList[i], sockstate.SelectedChar);
                        SMSG_SEND_SESSION sessionPkt = new SMSG_SEND_SESSION(sockstate.SelectedChar);

                        try
                        {
                            // notify world
                            Program.SquareList[i].Socket.Client.Socket.Send(sessionPkt.Stream);
                        }
                        catch(Exception)
                        {
                            Logger.Log(Logger.LogLevel.Access, "World Server", "Server {0} not responding", Program.SquareList[i].Name);
                            Program.SquareList.RemoveAt(i);
                        }

                        // notify client
                        sockstate.Client.PacketQueue.Enqueue(spkt.Stream);

                        break;
                    }
                }
            }
        }