Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 582 Bytes

README.md

File metadata and controls

37 lines (29 loc) · 582 Bytes

golang socket.io client

example

package main

import (
	"fmt"
	"net/http"
	"time"

	socketio "github.com/leviathan-1776/socketio-client-go"
)

func main() {
	var header http.Header = map[string][]string{}
	s, err := socketio.Socket("ws://127.0.0.1:3000")
	if err != nil {
		panic(err)
	}
	s.Connect(header)
	s.On("message", func(args ...interface{}) {
		fmt.Println(args[0])
	})
	for {
		s.Emit("message", "hello server!")
		time.Sleep(2 * time.Second)
	}
}

server