-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type check conversations and events #87
base: master
Are you sure you want to change the base?
Conversation
I'm responding here for context. The change around the events is that the API would only emit two kinds of events: this.messagesPoller = new MessagesPoller(this.io, this.context);
this.messagesPoller.on("error", (err: Error) => this.emit("error", err)); (source) Currently, there are 4 events: The bigger change is around the event object. // Current version
api.on("event", (event: EventMessage) => {...});
// Version in this PR
api.on("event", (event: SkypeEvent) => {...}); This change means two things:
Now, how do you deal with these new Skype events? To clarify: // Curent version
api.on("event", (event: EventMessage) => {
// "ConversationUpdate" or "NewMessage"
if (event.resourceType === "ConversationUpdate") {
console.log("Received conversation update");
} else { // "NewMessage"
switch (event.resource.type) {
case "RichText":
console.log(event.resource.from); // A parsed user ID (MRI key)
console.log(event.resource.content);
console.log(event.resource.clientId); // Message ID assigned by the client
default:
// ...
}
}
});
// Version in this PR:
api.on("event", (event: SkypeEvent) => {
switch (event.resourceType) {
case EventResourceType.EndpointPresenceEvent:
console.log("Connection to a new endpoint");
break;
case EventResourceType.UserPresenceEvent:
console.log("New user connection");
break;
case EventResourceType.NewMessageEvent:
switch (event.resource.messageType) {
case "RichText":
console.log(event.resource.from); // An absolute URL (a helper should be provided for this)
console.log(event.resource.content);
console.log(event.resource.clientMessageId); // Message ID assigned by the client (renamed)
default:
// ...
}
break;
}
}); This PR needs at least the following changes:
|
@demurgos |
I think the easiest way to work on this would be to merge this first and then but I don't think I'll have time to finish it immediately. It will probably be done by the end of February. Having most of the message types figured out would be great: it will probably be the main focus of the next version. I started to collect some examples of JSON messages. |
This is a large PR introducing a change similar to the contact API: it moves the focus of the library on abstracting HTTP calls and guaranteeing the return values, and minimizing renaming or other normalizations.
The immediate benefit is that the skype events are now more rich: the API exposes the all the available data.
One of the downsides is that there is no more
conversationId
on message events: you have aconversationLink
instead and have to retrieve the id manually. Next PRs should adds helpers to facilitate this.