Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.
/ tcp.io Public archive

Real-Time event-based communication library for Go Lang, inspired by socket.io

License

Notifications You must be signed in to change notification settings

flewsoftware/tcp.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is TCP.IO

TCP.IO enables real-time bidirectional event-based communication. Inspired by Socket.IO,
⚠ TCP.IO IS NOT READY FOR PRODUCTION

What can I use it for

  • To create messaging apps
  • To create real-time apps

How to use

server:

package main
import (
    "fmt"
    "log"
    "tcpio/events"
    "tcpio/server"
)

func main() {
    io := server.Create(server.Config{Addr: ":8000"})
    io.On(events.Connection, func(socket server.Socket) {
    	socket.On("response", func(bytes []byte) {
            fmt.Println(string(bytes))
        })
        socket.Emit("request", []byte("ask"))
    })
    err := io.Listen()
    if err != nil {
        log.Fatalln(err)
    }
}

client:

package main
import (
    "fmt"
    "tcpio/client"
    "tcpio/events"
)
    
func main() {
	c := client.Create(client.Config{Addr: ":8000"})
	c.On(events.Connection, func(socket client.Socket) {
		socket.On("request", func(bytes []byte) {
            fmt.Println(string(bytes))
            socket.Emit("response", []byte("give"))
        })
    })
    c.Connect()
}

About

Real-Time event-based communication library for Go Lang, inspired by socket.io

Resources

License

Stars

Watchers

Forks

Languages