Ejemplo n.º 1
0
        public override string ToString()
        {
            string Msg;

            if (Opponent != null)
            {
                Msg = Id.ToString() + ',' + Owner.Name + ',' + Opponent.Name + ',' + NumOfPlayers + ',' + Level + ',' + Category + ',' + Join.ToString() + ',' + Word + ';';
            }
            else
            {
                Msg = Id.ToString() + ',' + Owner.Name + ',' + "" + ',' + NumOfPlayers + ',' + Level + ',' + Category + ',' + Join.ToString() + ',' + Word + ';';
            }
            return(Msg);
        }
        public void RUN()
        {
            CheckForIllegalCrossThreadCalls = false;    // cross thread false

            //MessageBox.Show("TTT");

            //this.m_listener = new TcpListener(7777);
            //this.m_listener.Start();

            //m_listener = null;
            IPAddress locAddr = IPAddress.Parse(textBox_IP.Text);/* int port = 13000;*/

            m_listener = new TcpListener(locAddr, Int32.Parse(textBox_PortNumber.Text));
            //server = new TcpListener(IPAddress.Parse("127.0.0.1"), 13002);
            m_listener.Start();
            if (!this.m_bClientOn)
            {
                this.Invoke(new MethodInvoker(delegate()
                {
                    TextBox_ServerLog.Text = ("Server - Start\n");
                    TextBox_ServerLog.AppendText(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test" + "\n"); //저장 파일 폴더
                    System.IO.Directory.CreateDirectory(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test"); // 없다면 생성 되도록 함
                    if (this.m_file_writer == null)
                    {
                        this.m_file_writer = new StreamWriter(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test" + "\\member.txt", true);
                    }
                    m_file_writer.Flush();
                    m_file_writer.Close();
                    m_file_writer      = null;
                    this.m_file_reader = new StreamReader(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test" + "\\member.txt");
                    ////처음으로 돌립니다.
                    //if (this.m_file_reader.Peek() < 0) this.m_file_reader.BaseStream.Seek(0, SeekOrigin.Begin);

                    //리스트뷰에 넣기
                    int i = 1;
                    while (m_file_reader.Peek() >= 0)
                    {
                        ListViewItem item = new ListViewItem(i.ToString());
                        foreach (string ohohstring in m_file_reader.ReadLine().Split(new char[] { ',' }))
                        {
                            item.SubItems.Add(ohohstring);
                        }
                        MemberList.Items.Add(item);
                        i++;
                    }
                    this.m_file_reader.Close();
                    this.m_file_reader = null;
                    //MessageBox.Show("멤버 파일을 모두 읽어 왔습니다.");
                    //this.m_file_writer = File.AppendText("log.txt");
                }));
            }
            //MessageBox.Show("저 여기서 기다리고 있씁니다.");
            TextBox_ServerLog.AppendText("Waiting for a connection...\n");
            TcpClient client = m_listener.AcceptTcpClient();

            if (client.Connected)
            {
                this.m_bClientOn = true;
                this.Invoke(new MethodInvoker(delegate()
                {
                    TextBox_ServerLog.AppendText("Client Access!!\n");
                }));
                m_networkstream = client.GetStream();
            }
            //listening loop // 여기 무한 루프라서 안 되네
            int nRead = 0;

            //MessageBox.Show("여기는 오니?");
            while (this.m_bClientOn)
            {
                //MessageBox.Show("TTTTT");

                try
                {
                    nRead = 0;
                    //MessageBox.Show("AAAA");

                    nRead = this.m_networkstream.Read(readBuffer, 0, 1024 * 1024 * 4); //여기서 멈춰있나

                    Packet packet = (Packet)Packet.Desserialize(this.readBuffer);      //이거 까지 올려야되나
                    switch ((int)packet.Type)
                    {
                    case (int)PacketType.회원가입:
                    {
                        this.m_joinClass = (Join)Packet.Desserialize(this.readBuffer);
                        int a = 0;
                        this.Invoke(new MethodInvoker(delegate()
                            {
                                for (int i = 0; i < MemberList.Items.Count; i++)    //같은거 확인하려고 했는데 안되네
                                {
                                    if (m_joinClass.m_strID.Equals(MemberList.Items[i].SubItems[1].Text))
                                    {
                                        Join joinClass = new Join();
                                        joinClass.Type = (int)PacketType.회원가입;
                                        joinClass.Data = 1;
                                        joinClass.str  = "이미 사용중인 ID입니다.";
                                        Packet.Serialize(joinClass).CopyTo(this.sendBuffer, 0);
                                        this.Send();
                                        a = 1;
                                        break;
                                    }
                                }
                                if (a != 1)
                                {
                                    ListViewItem item;
                                    item = MemberList.Items.Add((MemberList.Items.Count + 1).ToString()); //오예 추가된다 기모띠
                                    item.SubItems.Add(this.m_joinClass.m_strID);
                                    item.SubItems.Add(this.m_joinClass.m_strPassword);                    //회원 가입 완료
                                    this.TextBox_ServerLog.AppendText(this.m_joinClass.m_strID + " >> Join\n");
                                    if (this.m_file_writer == null)
                                    {
                                        this.m_file_writer = new StreamWriter(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test" + "\\member.txt", true);
                                    }
                                    System.IO.Directory.CreateDirectory(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test\\" + this.m_joinClass.m_strID);  // 개인 폴더 생성

                                    m_file_writer.WriteLine(this.m_joinClass.m_strID + "," + this.m_joinClass.m_strPassword);
                                    m_file_writer.Flush();
                                    m_file_writer.Close();
                                    m_file_writer = null;
                                    //System.IO.Directory.CreateDirectory(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test\\"+ this.m_joinClass.m_strID);// 없다면 생성 되도록 함

                                    Join joinClass = new Join();
                                    joinClass.Type = (int)PacketType.회원가입;
                                    joinClass.Data = 0;
                                    Packet.Serialize(joinClass).CopyTo(this.sendBuffer, 0);
                                    this.Send();
                                }
                            }));
                        break;
                    }

                    case (int)PacketType.로그인:
                    {
                        this.m_loginClass = (Login)Packet.Desserialize(this.readBuffer);
                        int a = 0;
                        this.Invoke(new MethodInvoker(delegate()
                            {
                                //MessageBox.Show(MemberList.Items.Count.ToString());//Test
                                for (int i = 0; i < MemberList.Items.Count; i++)    //가입 확인하고 로그인 시켜주자
                                {
                                    //MessageBox.Show(MemberList.Items[i].SubItems[1].Text);
                                    if (m_loginClass.m_strID.Equals(MemberList.Items[i].SubItems[1].Text))    //왜 이게 안되지??
                                    {
                                        this.TextBox_ServerLog.AppendText(this.m_loginClass.m_strID + " >> Login\n");
                                        Login loginClass = new Login();
                                        loginClass.Type  = (int)PacketType.로그인;
                                        loginClass.Data  = 0;
                                        Packet.Serialize(loginClass).CopyTo(this.sendBuffer, 0);
                                        this.Send();
                                        a = 1;
                                        break;
                                    }
                                }
                                if (a != 1)
                                {
                                    a = 0;
                                    Login loginClass = new Login();
                                    loginClass.Type  = (int)PacketType.로그인;
                                    loginClass.Data  = 1;
                                    loginClass.str   = "ID 또는 PW가 잘못되었습니다.\n계정이 없다면 회원가입 버튼을 통해 계정을 만드십시오!";
                                    Packet.Serialize(loginClass).CopyTo(this.sendBuffer, 0);
                                    this.Send();
                                }
                            }));
                        break;
                    }

                    case (int)PacketType.조회:
                    {
                        this.m_searchClass = (Search)Packet.Desserialize(this.readBuffer);
                        int a = 0;
                        this.Invoke(new MethodInvoker(delegate()
                            {
                                List <String> parts = new List <String>();
                                for (int i = 0; i < MemberList.Items.Count; i++)    //같은거 확인하려고 했는데 안되네
                                {
                                    if (m_searchClass.m_strID.Equals(MemberList.Items[i].SubItems[1].Text))
                                    {
                                        continue;
                                    }
                                    parts.Add(MemberList.Items[i].SubItems[1].Text);
                                    //MessageBox.Show(parts[i]);
                                }
                                Search searchClass = new Search();
                                searchClass.Type   = (int)PacketType.조회;
                                searchClass.Data   = 0;
                                searchClass.m_list = parts;
                                Packet.Serialize(searchClass).CopyTo(this.sendBuffer, 0);
                                this.Send();
                                //MessageBox.Show("보냈쪄");
                            }));
                        break;
                    }

                    case (int)PacketType.업로드:
                    {
                        this.m_uploadClass = (Upload)Packet.Desserialize(this.readBuffer);
                        int a = 0;
                        this.Invoke(new MethodInvoker(delegate()
                            {
                                const string fileName = "Test#@@#.dat";
                                using (FileStream
                                       fileStream = new FileStream(fileName, FileMode.Create))
                                {
                                    for (int i = 0; i < m_uploadClass.m_byte.Length; i++)
                                    {
                                        fileStream.WriteByte(m_uploadClass.m_byte[i]);
                                    }
                                    Image img = System.Drawing.Image.FromStream(fileStream);

                                    img.Save(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test\\" + this.m_loginClass.m_strID + "\\" + m_uploadClass.m_filename);
                                }
                                MessageBox.Show("수신 완료\n경로 : " + Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test\\" + this.m_loginClass.m_strID + "\\" + m_uploadClass.m_filename);
                                //if (this.m_file_writer == null)
                                //	this.m_file_writer = new StreamWriter(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test" + this.m_loginClass.m_strID + "\\" +"message.txt", true);
                                ////System.IO.Directory.CreateDirectory(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\test\\" + this.m_joinClass.m_strID);// 개인 폴더 생성

                                //m_file_writer.WriteLine(m_uploadClass.m_message);
                                //m_file_writer.Flush();
                                //m_file_writer.Close();
                                //m_file_writer = null;

                                //MessageBox.Show();


                                //Search searchClass = new Search();
                                //searchClass.Type = (int)PacketType.조회;
                                //searchClass.Data = 0;
                                //searchClass.m_list = parts;
                                //Packet.Serialize(searchClass).CopyTo(this.sendBuffer, 0);
                                //this.Send();
                            }));
                        break;
                    }
                    }
                }
                catch
                {
                    this.m_bClientOn     = false;
                    this.m_networkstream = null;
                    break;//오 이러니까 되는거 같다. 개꿀 또 안되네 뭐지
                }
            }
        }
Ejemplo n.º 3
0
        public void ProcessPacket(int packetID, Player player)
        {
            switch ((PacketID)packetID)
            {
            case PacketID.entityUpdate:
                #region entity update
                var    entityUpdate = new EntityUpdate(player.reader);
                string ACmessage    = AntiCheat.Inspect(entityUpdate);
                if (ACmessage != "ok")
                {
                    var kickMessage = new ChatMessage()
                    {
                        message = "illegal " + ACmessage
                    };
                    kickMessage.Write(player.writer, true);
                    Console.WriteLine(player.entityData.name + " kicked for illegal " + kickMessage.message);
                    Thread.Sleep(100);     //thread is about to run out anyway so np
                    Kick(player);
                    return;
                }
                if (entityUpdate.name != null)
                {
                    Announce.Join(entityUpdate.name, player.entityData.name, players);
                }

                entityUpdate.entityFlags |= 1 << 5;     //enable friendly fire flag for pvp
                if (!player.entityData.IsEmpty)
                {
                    entityUpdate.Filter(player.entityData);
                }
                if (!entityUpdate.IsEmpty)
                {
                    entityUpdate.Broadcast(players, 0);
                    if (entityUpdate.HP == 0 && player.entityData.HP > 0)
                    {
                        Tomb.Show(player).Broadcast(players, 0);
                    }
                    else if (player.entityData.HP == 0 && entityUpdate.HP > 0)
                    {
                        Tomb.Hide(player).Broadcast(players, 0);
                    }
                    entityUpdate.Merge(player.entityData);
                }
                break;

                #endregion
            case PacketID.entityAction:
                #region action
                EntityAction entityAction = new EntityAction(player.reader);
                switch (entityAction.type)
                {
                case ActionType.talk:
                    break;

                case ActionType.staticInteraction:
                    //var staticEntity = new StaticEntity();
                    //staticEntity.chunkX = entityAction.chunkX;
                    //staticEntity.chunkY = entityAction.chunkY;
                    //staticEntity.id = entityAction.index;
                    //staticEntity.type = 0;
                    //staticEntity.position = player.entityData.position;
                    //staticEntity.rotation = 0;
                    //staticEntity.size.x = 2;
                    //staticEntity.size.y = 1;
                    //staticEntity.size.z = 1;
                    //staticEntity.closed = 0;
                    //staticEntity.time = 1000;
                    //staticEntity.guid = player.entityData.guid;

                    //var serverUpdate = new ServerUpdate();
                    //serverUpdate.statics.Add(staticEntity);
                    //serverUpdate.Send(players, 0);
                    break;

                case ActionType.pickup:         //shouldn't occur since item drops are disabled
                    break;

                case ActionType.drop:         //send item back to dropper because dropping is disabled to prevent chatspam
                    var pickup = new ServerUpdate.Pickup()
                    {
                        guid = player.entityData.guid,
                        item = entityAction.item
                    };

                    var serverUpdate6 = new ServerUpdate();
                    serverUpdate6.pickups.Add(pickup);
                    serverUpdate6.Write(player.writer, true);
                    break;

                case ActionType.callPet:
                    var petItem = player.entityData.equipment[(int)Equipment.pet];

                    var pet = new EntityUpdate()
                    {
                        guid        = 2000 + player.entityData.guid,
                        position    = player.entityData.position,
                        hostility   = (int)Hostility.pet,
                        entityType  = 28,
                        appearance  = player.entityData.appearance,
                        HP          = 999,
                        parentOwner = 3000 + (long)player.entityData.guid,
                        equipment   = player.entityData.equipment,
                        name        = "doppelganger"
                    };
                    pet.Broadcast(players, 0);

                    pet = new EntityUpdate()
                    {
                        guid        = 3000 + player.entityData.guid,
                        position    = player.entityData.position,
                        hostility   = (int)Hostility.pet,
                        entityType  = 28,
                        mode        = 106,
                        appearance  = player.entityData.appearance,
                        HP          = 999,
                        parentOwner = (long)player.entityData.guid,
                        equipment   = player.entityData.equipment,
                        name        = "doppelganger"
                    };
                    pet.Broadcast(players, 0);
                    break;

                default:
                    Console.WriteLine("unknown action (" + entityAction.type + ") by " + player.entityData.name);
                    break;
                }
                break;

                #endregion
            case PacketID.hit:
                #region hit
                var hit = new Hit(player.reader);
                hit.damage *= 0.75f;
                if (players.ContainsKey(hit.target))
                {
                    var serverUpdate7 = new ServerUpdate();
                    serverUpdate7.hits.Add(hit);
                    serverUpdate7.Broadcast(players, player.entityData.guid);
                }
                break;

                #endregion
            case PacketID.passiveProc:
                #region passiveProc
                var passiveProc = new PassiveProc(player.reader);

                var serverUpdate8 = new ServerUpdate();
                serverUpdate8.passiveProcs.Add(passiveProc);
                serverUpdate8.Broadcast(players, player.entityData.guid);

                switch (passiveProc.type)
                {
                case ProcType.warFrenzy:
                case ProcType.camouflage:
                case ProcType.fireSpark:
                case ProcType.intuition:
                case ProcType.elusivenes:
                case ProcType.swiftness:
                    //nothing particular yet
                    break;

                case ProcType.manashield:
                    var chatMessage6m = new ChatMessage()
                    {
                        message = string.Format("manashield: {0}", passiveProc.modifier),
                        sender  = 0
                    };
                    chatMessage6m.Write(player.writer, true);
                    break;

                case ProcType.bulwalk:
                    var chatMessage6b = new ChatMessage()
                    {
                        message = string.Format("bulwalk: {0}% dmg reduction", 1.0f - passiveProc.modifier),
                        sender  = 0
                    };
                    chatMessage6b.Write(player.writer, true);
                    break;

                case ProcType.poison:
                    if (players.ContainsKey(passiveProc.target))        //in case target is a tomb or sth
                    {
                        var poisonDmg = new Hit()
                        {
                            attacker = passiveProc.source,
                            target   = passiveProc.target,
                            damage   = passiveProc.modifier,
                            position = players[passiveProc.target].entityData.position,
                            type     = DamageType.normal
                        };
                        var poisonTick = new ServerUpdate();
                        poisonTick.hits.Add(poisonDmg);
                        Poison(poisonTick, passiveProc.duration);
                    }
                    break;

                default:
                    Console.WriteLine("unknown passiveProc.type: " + passiveProc.type);
                    break;
                }
                break;

                #endregion
            case PacketID.shoot:
                #region shoot
                var shoot = new Shoot(player.reader);

                var serverUpdate9 = new ServerUpdate();
                serverUpdate9.shoots.Add(shoot);
                serverUpdate9.Broadcast(players, player.entityData.guid);
                break;

                #endregion
            case PacketID.chat:
                #region chat
                var chatMessage = new ChatMessage(player.reader)
                {
                    sender = player.entityData.guid
                };

                if (chatMessage.message.StartsWith("/"))
                {
                    string parameter = "";
                    string command   = chatMessage.message.Substring(1);
                    if (chatMessage.message.Contains(" "))
                    {
                        int spaceIndex = command.IndexOf(" ");
                        parameter = command.Substring(spaceIndex + 1);
                        command   = command.Substring(0, spaceIndex);
                    }
                    Command.TCP(command, parameter, player);     //wip
                }
                else
                {
                    chatMessage.Broadcast(players, 0);
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write("#" + player.entityData.guid + " " + player.entityData.name + ": ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(chatMessage.message);
                }
                break;

                #endregion
            case PacketID.chunk:
                #region chunk
                var chunk = new Chunk(player.reader);
                break;

                #endregion
            case PacketID.sector:
                #region sector
                var sector = new Chunk(player.reader);
                break;

                #endregion
            case PacketID.version:
                #region version
                var version = new ProtocolVersion(player.reader);
                if (version.version != 3)
                {
                    version.version = 3;
                    version.Write(player.writer, true);
                    player.tcp.Close();
                }
                else
                {
                    player.entityData.guid = guidCounter;
                    guidCounter++;

                    var join = new Join()
                    {
                        guid = player.entityData.guid,
                        junk = new byte[0x1168]
                    };
                    join.Write(player.writer, true);

                    var mapSeed = new MapSeed()
                    {
                        seed = Database.mapseed
                    };
                    mapSeed.Write(player.writer, true);

                    foreach (Player p in players.Values)
                    {
                        p.entityData.Write(player.writer);
                    }
                    players.Add(player.entityData.guid, player);
                    Task.Delay(10000).ContinueWith(t => Load_world_delayed(player));     //WIP, causes crash when player disconnects before executed
                }
                break;

                #endregion
            default:
                Console.WriteLine("unknown packet ID: " + packetID);     //causes some console spam, but allows resyncing with the player without DC or crash
                break;
            }
        }
Ejemplo n.º 4
0
        /* 서버 시작 */
        public void ServerStart()
        {
            try
            {
                _port     = Convert.ToInt32(txtPort.Text);
                _listener = new TcpListener(_port);
                _listener.Start();
                _isStart = true;

                DirectoryInfo di = new DirectoryInfo(_storage);
                if (di.Exists == false)
                {
                    di.Create();
                }

                LoadMemberList();

                this.Invoke(new MethodInvoker(delegate()
                {
                    txtLog.AppendText("Server - Start\n");
                    txtLog.AppendText("Storage Path : C:\\Instagram_server\\\n");
                    txtLog.AppendText("waiting for client access...\n");
                }));

                while (_isStart)
                {
                    TcpClient client = _listener.AcceptTcpClient();

                    if (client.Connected)
                    {
                        _isConnect = true;
                        this.Invoke(new MethodInvoker(delegate()
                        {
                            txtLog.AppendText("Client Access !!\n");
                        }));
                        _networkstream = client.GetStream();

                        int nRead = 0;
                        while (_isConnect)
                        {
                            try
                            {
                                nRead = 0;
                                for (int i = 0; i < _readBuffer.Length; i += (1024 * 4))
                                {
                                    nRead = _networkstream.Read(_readBuffer, i, 1024 * 4);
                                }
                            }
                            catch
                            {
                                _isConnect = false;
                                _networkstream.Close();
                                _networkstream = null;
                            }


                            Packet packet = (Packet)Packet.Desserialize(_readBuffer);

                            switch ((int)packet.Type)
                            {
                            case (int)PacketType.QUIT:
                            {
                                _isConnect = false;
                                break;
                            }

                            case (int)PacketType.JOIN:
                            {
                                _isError    = false;
                                _joinMember = (Join)Packet.Desserialize(_readBuffer);
                                _fileReader = new StreamReader(_storage + "member.txt");
                                while (_fileReader.Peek() >= 0)
                                {
                                    if (_joinMember._id.Equals(_fileReader.ReadLine()))
                                    {
                                        Msg msg = new Msg();
                                        msg._text = "이미 사용중인 ID 입니다.";
                                        msg.Type  = (int)PacketType.MSG;
                                        Packet.Serialize(msg).CopyTo(_sendBuffer, 0);
                                        Send();
                                        _isError = true;
                                        break;
                                    }
                                    _fileReader.ReadLine();
                                }
                                _fileReader.Close();
                                _fileReader.Dispose();
                                _fileReader = null;

                                if (_isError)
                                {
                                    break;
                                }
                                else
                                {
                                    _fileWriter = new StreamWriter(_storage + "member.txt", true);
                                    _fileWriter.WriteLine(_joinMember._id);
                                    _fileWriter.WriteLine(_joinMember._password);
                                    _fileWriter.Flush();
                                    _fileWriter.Close();
                                    _fileWriter.Dispose();
                                    _fileWriter = null;
                                    this.Invoke(new MethodInvoker(delegate()
                                        {
                                            txtLog.AppendText(_joinMember._id + " >> Join\n");
                                        }));
                                    LoadMemberList();

                                    Msg msg = new Msg();
                                    msg._text = "회원가입이 정상적으로 완료되었습니다 !";
                                    msg.Type  = (int)PacketType.MSG;
                                    Packet.Serialize(msg).CopyTo(_sendBuffer, 0);
                                    Send();
                                    break;
                                }
                            }

                            case (int)PacketType.LOGIN:
                            {
                                try
                                {
                                    _isError     = true;
                                    _loginMember = (Login)Packet.Desserialize(_readBuffer);
                                    _fileReader  = new StreamReader(_storage + "member.txt");
                                    while (_fileReader.Peek() >= 0)
                                    {
                                        if (_loginMember._id.Equals(_fileReader.ReadLine()))
                                        {
                                            if (_loginMember._password.Equals(_fileReader.ReadLine()))
                                            {
                                                _isError = false;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            _fileReader.ReadLine();
                                        }
                                    }
                                    _fileReader.Close();
                                    _fileReader.Dispose();
                                    _fileReader = null;

                                    if (_isError)
                                    {
                                        Msg msg = new Msg();
                                        msg._text = "ID 또는 PW가 잘못되었습니다.\n계정이 없다면 회원가입 버튼을 통해 계정을 만드십시오!";
                                        msg.Type  = (int)PacketType.MSG;
                                        Packet.Serialize(msg).CopyTo(_sendBuffer, 0);
                                        Send();
                                        break;
                                    }
                                    else
                                    {
                                        DirectoryInfo memberDi = new DirectoryInfo(_storage + _loginMember._id);
                                        if (memberDi.Exists == false)
                                        {
                                            memberDi.Create();
                                        }
                                        _loginMember._postnum = memberDi.GetFiles().Length / 2;

                                        Msg msg = new Msg();
                                        msg._text = "LogIn";
                                        msg._memo = _loginMember._postnum.ToString();
                                        msg.Type  = (int)PacketType.MSG;
                                        Packet.Serialize(msg).CopyTo(_sendBuffer, 0);
                                        Send();
                                        this.Invoke(new MethodInvoker(delegate()
                                            {
                                                txtLog.AppendText(_loginMember._id + " >> LogIn\n");
                                            }));

                                        Member memberList = new Member();
                                        string otherMember;
                                        _fileReader = new StreamReader(_storage + "member.txt");
                                        while (_fileReader.Peek() >= 0)
                                        {
                                            otherMember = _fileReader.ReadLine();
                                            if (!_loginMember._id.Equals(otherMember))
                                            {
                                                memberList._list += otherMember + "\n";
                                            }
                                            _fileReader.ReadLine();
                                        }
                                        memberList.Type = (int)PacketType.MEMBER;
                                        Packet.Serialize(memberList).CopyTo(_sendBuffer, 0);
                                        Send();
                                        _fileReader.Close();
                                        _fileReader.Dispose();
                                        _fileReader = null;

                                        for (int i = 0; i < _loginMember._postnum; i++)
                                        {
                                            Post  post  = new Post();
                                            Image image = (Image)(Image.FromFile(_storage + _loginMember._id + "\\" + i.ToString() + ".jpg").Clone());
                                            _fileReader = new StreamReader(_storage + _loginMember._id + "\\" + i.ToString());
                                            post._image = image;
                                            while (_fileReader.Peek() >= 0)
                                            {
                                                post._text += _fileReader.ReadLine();
                                            }
                                            post.Type = (int)PacketType.MYPAGE;
                                            Packet.Serialize(post).CopyTo(_sendBuffer, 0);
                                            Send();
                                            _fileReader.Close();
                                            _fileReader.Dispose();
                                            _fileReader = null;
                                        }
                                        break;
                                    }
                                }
                                catch
                                {
                                    break;
                                }
                            }

                            case (int)PacketType.POST:
                            {
                                _isError = false;
                                try
                                {
                                    _post = (Post)Packet.Desserialize(_readBuffer);
                                    Image image = (Image)_post._image;
                                    image.Save(_storage + _loginMember._id + "\\" + _loginMember._postnum + ".jpg");
                                    _fileWriter = new StreamWriter(_storage + _loginMember._id + "\\" + _loginMember._postnum);
                                    _fileWriter.WriteLine(_post._text);

                                    Post post = new Post();
                                    post._image = image;
                                    post._text  = _post._text;
                                    post.Type   = (int)PacketType.MYPAGE;
                                    Packet.Serialize(post).CopyTo(_sendBuffer, 0);
                                    Send();
                                    _fileWriter.Flush();
                                    _fileWriter.Close();
                                    _fileWriter.Dispose();
                                    _fileWriter = null;
                                    _loginMember._postnum++;
                                }
                                catch
                                {
                                    _isError = true;
                                }

                                if (!_isError)
                                {
                                    Msg msg = new Msg();
                                    msg._text = "성공적으로 업로드하였습니다 ! 마이페이지에서 확인하십시오.";
                                    msg._memo = _loginMember._postnum.ToString();
                                    msg.Type  = (int)PacketType.MSG;
                                    Packet.Serialize(msg).CopyTo(_sendBuffer, 0);
                                    Send();
                                }
                                else
                                {
                                    Msg msg = new Msg();
                                    msg._text = "업로드 실패";
                                    msg.Type  = (int)PacketType.MSG;
                                    Packet.Serialize(msg).CopyTo(_sendBuffer, 0);
                                    Send();
                                }
                                break;
                            }
                            }
                        }
                        if (!_isConnect)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        _isConnect = false;
                        _networkstream.Close();
                        _networkstream = null;
                    }
                }
            }
            catch
            {
                ServerStop();
                return;
            }
        }
 Task On(Join x) => Send(x.Room, $"{Id} joined the room {x.Room} ...");