Skip to content
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

Update Readme to show how to edit the PingInterval #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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