Example #1
0
        public override bool BeforeInvoke(InvocationInfo info, out object returnValue)
        {
            returnValue = null;
            Message m = (Message)info.Arguments()[0];

            // check whether it's a RoomEnterMessage, leave the RoomEnterFreeMessage because
            // we still want to join the first free room upon starting the game
            if (m is RoomEnterMessage && !(m is RoomEnterFreeMessage))
            {
                RoomEnterMessage rem = (RoomEnterMessage)m;

                // construct new RoomEnterMultiMessage with desired room
                RoomEnterMultiMessage remm = new RoomEnterMultiMessage(new String[]{ rem.roomName });
                // and send the request to the server.
                App.Communicator.sendRequest((Message)remm);

                // add the room to the UI, this isn't done automatically after RoomEnterMulti,
                // only after RoomEnter which this isn't.
                App.ArenaChat.ChatRooms.SetCurrentRoom(rem.roomName);

                // ... and stop the method from executing :)
                return true;
            }

            return false;
        }