Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,38 @@ var socket = io('ws://yourdomain.com', {transports: ['websocket']});
transport.GetDefaultWebsocketTransport(),
)

//do something, handlers and functions are same as server ones
//do something, handlers and functions are same as server ones. Example showing data poassed through and a switch on the data type being received.
_ = s.Client.On("callEventFromServer", func(c *gosocketio.Channel, j *interface{}) {

switch dataType := (*j).(type) {
case map[string]interface{}:
fmt.Println("received a map[string]interface:", dataType)
default:
fmt.Printf("Unknown data type received in websocket: %v data: %v", dataType, *j)
}

})

_ = s.Client.On("getFaceCount", func(c *gosocketio.Channel) {
log.Printf("on getFaceCount with no message:\n")
})

//close connection
c.Close()
```

To configure custom transport settings, like changing the default PingInterval:
```
tr := transport.GetDefaultWebsocketTransport()
tr.PingInterval = 20 * time.Second

c, err := gosocketio.Dial(
connectionUrl,
tr,
)
```


### Roadmap

1. Tests
Expand Down