Implement Poke functionality, refine talking status and add local log events
This commit is contained in:
@@ -124,6 +124,10 @@ func (c *Client) emit(event EventType, data any) {
|
||||
if fn, ok := h.(func(*TalkingStatusEvent)); ok {
|
||||
fn(data.(*TalkingStatusEvent))
|
||||
}
|
||||
case EventPoke:
|
||||
if fn, ok := h.(func(*PokeEvent)); ok {
|
||||
fn(data.(*PokeEvent))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,6 +409,13 @@ func (c *Client) handleInternalEvent(eventType string, data map[string]any) {
|
||||
Channels: getInt(data, "channels"),
|
||||
})
|
||||
|
||||
case "client_poke":
|
||||
c.emit(EventPoke, &PokeEvent{
|
||||
SenderID: getUint16(data, "senderID"),
|
||||
SenderName: getString(data, "senderName"),
|
||||
Message: getString(data, "message"),
|
||||
})
|
||||
|
||||
case "error":
|
||||
c.emit(EventError, &ErrorEvent{
|
||||
ID: getString(data, "id"),
|
||||
|
||||
@@ -25,8 +25,18 @@ const (
|
||||
|
||||
// Error events
|
||||
EventError EventType = "error"
|
||||
|
||||
// Poke events
|
||||
EventPoke EventType = "poke"
|
||||
)
|
||||
|
||||
// PokeEvent is emitted when a poke message is received
|
||||
type PokeEvent struct {
|
||||
SenderID uint16
|
||||
SenderName string
|
||||
Message string
|
||||
}
|
||||
|
||||
// ConnectedEvent is emitted when the client successfully connects
|
||||
type ConnectedEvent struct {
|
||||
ClientID uint16
|
||||
|
||||
Reference in New Issue
Block a user