Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
github.com/corvuscrypto/gpoll
Long-polling server package for Go. Meant to be generic enough to work with any server generated with go. Features automated client management and coroutine (goroutine) generation and termination based on default or custom settings so you can optimize your long-polling application.
GoDoc available at http://godoc.org/github.com/corvuscrypto/gpoll
A basic example of starting a server is:
package main
import (
"github.com/corvuscrypto/gpoll"
"net/http"
)
func HandleMessage(w http.ResponseWriter, r *http.Request) {
/* code to detect message and do other stuff as
you please with the request. */
var msg string = "blah blah blah"
gpoll.Send(msg) //send the message string
w.WriteHeader(200)
}
func main(){
gpoll.ListenAndBroadcast("/path/to/listen/on")
http.HandleFunc("/send", HandleMessage)
http.ListenAndServe(":8080",nil)
}
And it's as easy as that!!
If you are using this package, the one rule that keeps this server ticking is that you must keep track of the uuid the server sends back after initializing the polling connection. This is actually not a bad thing since in most cases it is good to track your clients anonymously, but before allowing the poll to go through properly the gpoll package always expects a query with at least the following query:
?client-id=x$xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
The gpoll package uses this to maintain its routines and retrieve the proper channels to listen for messages. If you send an improper id, then you will receive an Error 404 response. To initiate a client properly so the server returns a uuid to use for subsequent polls, send the following query:
?client-id=0
the identifier before the $
points to the goroutine that is tracking that client. The stuff after the $
is the actual client ID.
go test -bench
suite) for fine tuning performance to fit your machine.FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.