private GameCoordinatorMessage(GameCoordinatorMessageType messageType, bool protobuf, Header header, Body body)
 {
     MessageType = messageType;
     Protobuf    = protobuf;
     Header      = header;
     _body       = body;
 }
 /// <summary>
 /// Unsubscribes the specified receiver from messages of the specified type
 /// </summary>
 /// <param name="type"></param>
 /// <param name="receiver"></param>
 public void Unsubscribe(GameCoordinatorMessageType type, GameCoordinatorReceiver receiver)
 {
     if (!_dispatchers.ContainsKey(type))
     {
         _dispatchers[type] -= receiver;
     }
 }
 protected internal async Task SendAsync(GameCoordinatorMessageType messageType, bool protobuf, byte[] data)
 {
     await SendAsync(NetworkMessage
                     .CreateAppRoutedMessage(MessageType.ClientToGC,
                                             new CMsgGCClient
     {
         appid   = (uint)AppId,
         msgtype = MessageTypeUtils.MergeMessage((uint)messageType, protobuf),
         payload = data
     },
                                             AppId));
 }
        public static GameCoordinatorMessage CreateFromByteArray(GameCoordinatorMessageType type, bool protobuf, byte[] data)
        {
            using (MemoryStream stream = new MemoryStream(data))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    if (protobuf)
                    {
                        reader.ReadUInt32(); // read message type we already have
                        CMsgProtoBufHeader header;
                        using (MemoryStream protoStream = new MemoryStream(reader.ReadBytes(reader.ReadInt32())))
                            header = Serializer.Deserialize <CMsgProtoBufHeader>(protoStream);

                        return(new GameCoordinatorMessage(type, protobuf, new GameCoordinatorProtobufHeader(header), new ArraySegment <byte>(data, (int)stream.Position, (int)stream.Length - (int)stream.Position)));
                    }
                    else
                    {
                        reader.ReadUInt16(); // version, always 1
                        SteamGid target = reader.ReadUInt64();
                        SteamGid source = reader.ReadUInt64();
                        return(new GameCoordinatorMessage(type, protobuf, new Header(source), new ArraySegment <byte>(data, (int)stream.Position, (int)stream.Length - (int)stream.Position)));
                    }
                }
        }
 public static GameCoordinatorMessage CreateProtobufMessage(GameCoordinatorMessageType type, object value)
 {
     return(new GameCoordinatorMessage(type, true, new GameCoordinatorProtobufHeader(new CMsgProtoBufHeader()), value));
 }
 public static GameCoordinatorMessage CreateMessage(GameCoordinatorMessageType type, object value)
 {
     return(new GameCoordinatorMessage(type, false, new Header(SteamGid.Invalid), value));
 }
 private GameCoordinatorMessage(GameCoordinatorMessageType messageType, bool protobuf, Header header, ArraySegment <byte> body) : this(messageType, protobuf, header, new Body(body))
 {
 }
 private GameCoordinatorMessage(GameCoordinatorMessageType messageType, bool protobuf, Header header, object body) : this(messageType, protobuf, header, new Body(body))
 {
 }
 public GameCoordinatorReceiverAttribute(GameCoordinatorMessageType type)
 {
     Type = type;
 }