Presence Service

The Presence Service handles an entity's presence in Battle.net. Whenever an entity changes programs, parties, "away" status, or any other presence-related fields, the client will update the server, and the server will propagate that presence change to all relevant entities (including the sender).

= Data layout =

Fields
= Definition =

FieldKey
message FieldKey { required uint32 program = 1; required uint32 group = 2; required uint32 field = 3; optional uint64 index = 4 [default = 0]; }

Identification of a presence field.

Programs:
 * 16974 - 00 00 42 4E - BN\0\0
 * 17459 - 00 00 44 33 - D3\0\0
 * ? - StarCraft II
 * ? - World of Warcraft

Field
message Field { required .bnet.protocol.presence.FieldKey key = 1; required .bnet.protocol.attribute.Variant value = 2; }

A field's name and value.

FieldOperation
message FieldOperation { enum OperationType { SET = 0; CLEAR = 1; }   required .bnet.protocol.presence.Field field = 1; optional .bnet.protocol.presence.FieldOperation.OperationType operation = 2 [default = SET]; }

An encapsulating operation on a field.

SubscribeRequest
message SubscribeRequest { optional .bnet.protocol.EntityId agent_id = 1; required .bnet.protocol.EntityId entity_id = 2; required uint64 object_id = 3; }

A request to subscribe to this service.

UnsubscribeRequest
message UnsubscribeRequest { optional .bnet.protocol.EntityId agent_id = 1; required .bnet.protocol.EntityId entity_id = 2; }

A request to unsubscribe from this service.

UpdateRequest
message UpdateRequest { required .bnet.protocol.EntityId entity_id = 1; repeated .bnet.protocol.presence.FieldOperation field_operation = 2; }

A request to update the given entity's presence (usually character id).

QueryRequest / QueryResponse
message QueryRequest { required .bnet.protocol.EntityId entity_id = 1; repeated .bnet.protocol.presence.FieldKey key = 2; }

message QueryResponse { repeated .bnet.protocol.presence.Field field = 2; }

A request and response to query the presence of a given entity.

Subscribe
rpc Subscribe(.bnet.protocol.presence.SubscribeRequest) returns (.bnet.protocol.NoData);

Subscribe to the Presence service. When a client is subscribed, they should be sent Presence-related notifications.

Unsubscribe
rpc Unsubscribe(.bnet.protocol.presence.UnsubscribeRequest) returns (.bnet.protocol.NoData);

Unsubscribe from the Presence service. When a client is no longer subscribed, they should not be sent Presence-related notifications.

Update
rpc Update(.bnet.protocol.presence.UpdateRequest) returns (.bnet.protocol.NoData);

Update the client's presence. TODO: Document this more!

Query
rpc Query(.bnet.protocol.presence.QueryRequest) returns (.bnet.protocol.presence.QueryResponse);

Queries the presence of a given entity.