All Projects → sacOO7 → Gowebsocket

sacOO7 / Gowebsocket

Licence: apache-2.0
Gorilla websockets based simplified websocket-client implementation in GO.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gowebsocket

Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (+71.43%)
Mutual labels:  websocket, client
Websocket
A fast, well-tested and widely used WebSocket implementation for Go.
Stars: ✭ 16,070 (+20770.13%)
Mutual labels:  gorilla, websocket
Qtswissarmyknife
QSAK (Qt Swiss Army Knife) is a multi-functional, cross-platform debugging tool based on Qt.
Stars: ✭ 196 (+154.55%)
Mutual labels:  websocket, client
Python Binance Chain
Binance Chain Exchange API python implementation for automated trading
Stars: ✭ 96 (+24.68%)
Mutual labels:  websocket, client
Weevent
Event-Driven Architecture Based on Blockchain.基于区块链的事件驱动架构
Stars: ✭ 608 (+689.61%)
Mutual labels:  event-driven, websocket
Clusterws Client Js
🔥 JavaScript Client for ClusterWS - lightweight, fast and powerful framework for building scalable WebSocket applications in Node.js.
Stars: ✭ 120 (+55.84%)
Mutual labels:  websocket, client
Websocket
Gorilla WebSocket implementation for fasthttp.
Stars: ✭ 193 (+150.65%)
Mutual labels:  gorilla, websocket
Stompclientlib
Simple STOMP Client library, Swift 3 and 4, 4.2, 5 compatible
Stars: ✭ 99 (+28.57%)
Mutual labels:  websocket, client
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (+316.88%)
Mutual labels:  event-driven, websocket
Websocket Client
🔧 .NET/C# websocket client library
Stars: ✭ 297 (+285.71%)
Mutual labels:  websocket, client
Wstest
go websocket client for unit testing of a websocket handler
Stars: ✭ 83 (+7.79%)
Mutual labels:  gorilla, websocket
Ws Promise Client
PROJECT MOVED: https://github.com/kdex/ws-promise
Stars: ✭ 6 (-92.21%)
Mutual labels:  websocket, client
Workerman
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.
Stars: ✭ 9,617 (+12389.61%)
Mutual labels:  event-driven, websocket
Simple Websocket Server
A very simple, fast, multithreaded, platform independent WebSocket (WS) and WebSocket Secure (WSS) server and client library implemented using C++11, Boost.Asio and OpenSSL. Created to be an easy way to make WebSocket endpoints in C++.
Stars: ✭ 685 (+789.61%)
Mutual labels:  websocket, client
Zeus
A high performance, cross-platform Internet Communication Engine. Developed with native socket API. Aim at handling millions of concurrent connections.
Stars: ✭ 30 (-61.04%)
Mutual labels:  event-driven, client
Echofon Firefox Unofficial
Echofon Unofficial - maintained version of Echofon: full featured, super clean Twitter app for Firefox.
Stars: ✭ 73 (-5.19%)
Mutual labels:  client
C Sharp R.a.t Client
This is a c# client for the c# R.A.T server
Stars: ✭ 75 (-2.6%)
Mutual labels:  client
Bittorrent Tracker
🌊 Simple, robust, BitTorrent tracker (client & server) implementation
Stars: ✭ 1,184 (+1437.66%)
Mutual labels:  client
Cebsocket
Lightweight WebSocket library for C.
Stars: ✭ 73 (-5.19%)
Mutual labels:  websocket
Noduino
JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
Stars: ✭ 1,202 (+1461.04%)
Mutual labels:  websocket

GoWebsocket

Gorilla websocket based simplified client implementation in GO.

Overview

This client provides following easy to implement functionality

  • Support for emitting and receiving text and binary data
  • Data compression
  • Concurrency control
  • Proxy support
  • Setting request headers
  • Subprotocols support
  • SSL verification enable/disable

To install use

    go get github.com/sacOO7/gowebsocket

Description

Create instance of Websocket by passing url of websocket-server end-point

    //Create a client instance
    socket := gowebsocket.New("ws://echo.websocket.org/")
    

Important Note : url to websocket server must be specified with either ws or wss.

Connecting to server

  • For connecting to server:
    //This will send websocket handshake request to socketcluster-server
    socket.Connect()

Registering All Listeners

    package main
    
    import (
    	"log"
    	"github.com/sacOO7/gowebsocket"
        "os"
        "os/signal"
    )
    
    func main() {
    
        interrupt := make(chan os.Signal, 1)
        signal.Notify(interrupt, os.Interrupt)
        
    	socket := gowebsocket.New("ws://echo.websocket.org/");
    	
    	socket.OnConnected = func(socket gowebsocket.Socket) {
    		log.Println("Connected to server");
    	};
    	
        socket.OnConnectError = func(err error, socket gowebsocket.Socket) {
            log.Println("Recieved connect error ", err)
        };
        
    	socket.OnTextMessage = func(message string, socket gowebsocket.Socket) {
    		log.Println("Recieved message " + message)
    	};
    	
    	socket.OnBinaryMessage = func(data [] byte, socket gowebsocket.Socket) {
            log.Println("Recieved binary data ", data)
        };
        
    	socket.OnPingReceived = func(data string, socket gowebsocket.Socket) {
    		log.Println("Recieved ping " + data)
    	};
    	
    	socket.OnPongReceived = func(data string, socket gowebsocket.Socket) {
            log.Println("Recieved pong " + data)
        };
        
    	socket.OnDisconnected = func(err error, socket gowebsocket.Socket) {
    		log.Println("Disconnected from server ")
    		return
    	};
    	
    	socket.Connect()
    	
        for {
            select {
            case <-interrupt:
                log.Println("interrupt")
                socket.Close()
                return
            }
        }
    }
    

Sending Text message

    socket.SendText("Hi there, this is my sample test message")

Sending Binary data

    token := make([]byte, 4)
    // rand.Read(token) putting some random value in token
    socket.SendBinary(token)

Closing the connection with server

    socket.Close()

Setting request headers

	socket.RequestHeader.Set("Accept-Encoding","gzip, deflate, sdch")
	socket.RequestHeader.Set("Accept-Language","en-US,en;q=0.8")
	socket.RequestHeader.Set("Pragma","no-cache")
	socket.RequestHeader.Set("User-Agent","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36")
	

Setting proxy server

  • It can be set using connectionOptions by providing url to proxy server
    socket.ConnectionOptions = gowebsocket.ConnectionOptions {
       Proxy: gowebsocket.BuildProxy("http://example.com"),
    }

Setting data compression, ssl verification and subprotocols

  • It can be set using connectionOptions inside socket
    socket.ConnectionOptions = gowebsocket.ConnectionOptions {
        UseSSL:true,
        UseCompression:true,
        Subprotocols: [] string{"chat","superchat"},
    }
  • ConnectionOptions needs to be applied before connecting to server
  • Please checkout examples/gowebsocket directory for detailed code..

License

Apache License, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].