1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

use the same connection structure for both client and server-side connections interfaces, the 'Connection' interface could be changed to 'ServerConn' but this would produce breaking naming change to the iris users, so keep it as it's.

Former-commit-id: 3440871b368709e33d2d2a5080c66f7ad9338970
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-02-10 17:16:43 +02:00
parent 280872fd59
commit 946c100f7d
5 changed files with 258 additions and 296 deletions

View File

@@ -21,21 +21,21 @@ $ go run main.go
>> hi!
*/
func main() {
conn, err := websocket.Dial(url, websocket.DefaultEvtMessageKey)
c, err := websocket.Dial(url, websocket.ConnectionConfig{})
if err != nil {
panic(err)
}
conn.OnError(func(err error) {
c.OnError(func(err error) {
fmt.Printf("error: %v", err)
})
conn.OnDisconnect(func() {
fmt.Println("Server was force-closed[see ../server/main.go#L19] this connection after 20 seconds, therefore I am disconnected.")
c.OnDisconnect(func() {
fmt.Println("Server was force-closed[see ../server/main.go#L17] this connection after 20 seconds, therefore I am disconnected.")
os.Exit(0)
})
conn.On("chat", func(message string) {
c.On("chat", func(message string) {
fmt.Printf("\n%s\n", message)
})
@@ -51,7 +51,7 @@ func main() {
break
}
conn.Emit("chat", msgToSend)
c.Emit("chat", msgToSend)
}
fmt.Println("Terminated.")