Skip to content

Commit

Permalink
Merge pull request #1101 from struckchure/patch-1
Browse files Browse the repository at this point in the history
docs(readme): used `fmt.Printf` instead of `fmt.Println(fmt.Sprintf(.…
  • Loading branch information
ReneWerner87 authored May 16, 2024
2 parents 841f31a + 229ab65 commit 58db7f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions socketio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ func main() {

// Multiple event handling supported
socketio.On(socketio.EventConnect, func(ep *socketio.EventPayload) {
fmt.Println(fmt.Sprintf("Connection event 1 - User: %s", ep.Kws.GetStringAttribute("user_id")))
fmt.Printf("Connection event 1 - User: %s", ep.Kws.GetStringAttribute("user_id"))
})

// Custom event handling supported
socketio.On("CUSTOM_EVENT", func(ep *socketio.EventPayload) {
fmt.Println(fmt.Sprintf("Custom event - User: %s", ep.Kws.GetStringAttribute("user_id")))
fmt.Printf("Custom event - User: %s", ep.Kws.GetStringAttribute("user_id"))
// --->

// DO YOUR BUSINESS HERE
Expand All @@ -114,7 +114,7 @@ func main() {
// On message event
socketio.On(socketio.EventMessage, func(ep *socketio.EventPayload) {

fmt.Println(fmt.Sprintf("Message event - User: %s - Message: %s", ep.Kws.GetStringAttribute("user_id"), string(ep.Data)))
fmt.Printf("Message event - User: %s - Message: %s", ep.Kws.GetStringAttribute("user_id"), string(ep.Data))

message := MessageObject{}

Expand Down Expand Up @@ -148,20 +148,20 @@ func main() {
socketio.On(socketio.EventDisconnect, func(ep *socketio.EventPayload) {
// Remove the user from the local clients
delete(clients, ep.Kws.GetStringAttribute("user_id"))
fmt.Println(fmt.Sprintf("Disconnection event - User: %s", ep.Kws.GetStringAttribute("user_id")))
fmt.Printf("Disconnection event - User: %s", ep.Kws.GetStringAttribute("user_id"))
})

// On close event
// This event is called when the server disconnects the user actively with .Close() method
socketio.On(socketio.EventClose, func(ep *socketio.EventPayload) {
// Remove the user from the local clients
delete(clients, ep.Kws.GetStringAttribute("user_id"))
fmt.Println(fmt.Sprintf("Close event - User: %s", ep.Kws.GetStringAttribute("user_id")))
fmt.Printf("Close event - User: %s", ep.Kws.GetStringAttribute("user_id"))
})

// On error event
socketio.On(socketio.EventError, func(ep *socketio.EventPayload) {
fmt.Println(fmt.Sprintf("Error event - User: %s", ep.Kws.GetStringAttribute("user_id")))
fmt.Printf("Error event - User: %s", ep.Kws.GetStringAttribute("user_id"))
})

app.Get("/ws/:id", socketio.New(func(kws *socketio.Websocket) {
Expand Down

0 comments on commit 58db7f7

Please sign in to comment.