Example #1
0
        public bool InitiateTrade(uint UserOne, uint UserTwo)
        {
            Trade Trade = new Trade(UserOne, UserTwo);

            lock (mSyncRoot)
            {
                if (mTradeSessions.ContainsKey(UserOne) || mTradeSessions.ContainsKey(UserTwo))
                {
                    return false;
                }

                mTradeSessions.Add(UserOne, Trade);
                mTradeSessions.Add(UserTwo, Trade);
            }

            return true;
        }
Example #2
0
        public static ServerMessage Compose(Trade Trade)
        {
            List<Item> UserOneItems = Trade.UserOneOffers.Values.ToList();
            List<Item> UserTwoItems = Trade.UserTwoOffers.Values.ToList();

            ServerMessage Message = new ServerMessage(OpcodesOut.ROOM_TRADE_OFFERS);
            Message.AppendUInt32(Trade.UserOne);
            Message.AppendInt32(UserOneItems.Count);

            foreach (Item Item in UserOneItems)
            {
                SerializeTradeOffer(Message, Item);
            }

            Message.AppendUInt32(Trade.UserTwo);
            Message.AppendInt32(UserTwoItems.Count);

            foreach (Item Item in UserTwoItems)
            {
                SerializeTradeOffer(Message, Item);
            }

            return Message;
        }