A client for the Planetside 2 event streaming API.
This client is incomplete, however it has some basic functions that may be useful.
The best introduction is to read the simple example.
In short:
- You create and register callback functions for the client to call whenever it receives a new message.
let mut callbacks = CallbackHolder::new();
callbacks.register_event_listener(move |e| { println!("{:?}", e) });
// also available for more customization
callbacks.register_ps2_response_listener();
callbacks.register_all_response_listener();
- You create an event client, then connect it.
let mut event_client = EventStreamingClient::new(ENVIRONMENT, SERVICE_ID.to_owned(), callbacks);
event_client.connect().await.unwrap();
- You create and send a subscription request
let sub_request = EventRequest {
action:EventRequestAction::Subscribe,
service: Service::Event,
characters:Some(character_ids),
worlds:Some(worlds),
event_names:Some(events),
all: None,
list_characters: None,
payload: None
};
event_client.send_request(sub_request).await.unwrap();
- You start the client
event_client.run().await;
A simple use case, listening to events then printing out information about them.
Uses a channel to pass the events to another task for processing, allowing the processing thread to call the async functions provided to get additional information from the census api.
The main client for connecting to the event websocket service
A small set of helper functions that interact with the census rest api to get additional information about the data from the event streaming api.
Data types common to both the census and event client, most of them are just simple wrappers around primitive types.
Don't.