Beispiel #1
0
        public ByteBuffer getImageBuffer()
        {
            byte[]     files = FFactory.ReadFile(Share.USER_SAVE_PATH + "imgs/" + this.Image);
            ByteBuffer buf   = new ByteBuffer(-1, files.Length + 4);//125679

            buf.writeInt(files.Length);
            buf.writeBytes(files);
            return(buf);
        }
Beispiel #2
0
        public ByteBuffer RoomInfos(int roomId)
        {
            bool       isExt = false;
            ByteBuffer buf   = ByteBuffer.CreateByteBufferForLenth(100);

            buf.writeInt(Protcol.更新大厅某个房间信息);//6211
            Room r = rooms[roomId];

            //foreach (Room r in rms)
            {
                buf.writeInt(r.Roomid);
                buf.writeString(r.Roomname);
                buf.writeString(r.Password);
                User[] us = r.getUsers();
                buf.writeInt(us.Length);
                if (us.Length > 0)
                {
                    foreach (User u in us)
                    {
                        buf.writeString(u.ChinaName);
                        buf.writeInt(u.Image == null ? -1 : 1);
                        if (u.Image != null)
                        {
                            if (!isExt)
                            {
                                isExt = true;
                                buf.ExpansionCapacity(1000 * 1000 * us.Length + buf.Length);
                            }
                            byte[] files = FFactory.ReadFile(Share.USER_SAVE_PATH + "imgs/" + u.Image);
                            buf.writeInt(files.Length);
                            buf.writeBytes(files);
                        }
                    }
                }
            }
            return(buf);
        }