4 Commits

4 changed files with 60 additions and 7 deletions

2
.hgtags Normal file
View File

@@ -0,0 +1,2 @@
945ab4b16d05aa084f71bf5da9a3f687e0ec8bbd libnmdc-r1
02a360e95480b97ddad83add5db48b2766339a99 nmdc-log-service-1.0.0

View File

@@ -1,7 +0,0 @@
An NMDC client protocol library for Golang.
- Includes a sample logging client.
- This code hosting site isn't yet compatible with `go get`.
Written in golang
Tags: nmdc

View File

@@ -0,0 +1,20 @@
An NMDC client protocol library for Golang.
- Channel-based API.
- Includes a sample logging client.
- This code hosting site isn't (yet) compatible with `go get`.
Written in golang
Tags: nmdc
=CHANGELOG=
2016-04-02 r2
- Enhancement: Support NMDC-over-TLS (NMDCS)
- Fix an issue recieving private messages
- Fix an issue with calling `panic()` if connection failed
- Fix an issue parsing URIs without a specified port
- Move sample content into directory with excluded build
2016-02-12 r1
- Initial public release

View File

@@ -0,0 +1,38 @@
// +build ignore
// This sample file demonstrates use of the libnmdc.go library. It's excluded
// when building the library package, but you can run it via `go run libnmdc_sample.go`.
package main
import (
"fmt"
"libnmdc"
)
func main() {
opts := libnmdc.HubConnectionOptions{
Address: "127.0.0.1",
Self: libnmdc.UserInfo{Nick: "slowpoke9"},
}
hub := opts.Connect()
for {
event := <-hub.OnEvent
switch event.EventType {
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
fmt.Printf("Connection -- %s (%s)\n", event.StateChange.Format(), event.Message)
case libnmdc.EVENT_PUBLIC:
fmt.Printf("Message from '%s': '%s'\n", event.Nick, event.Message)
if event.Message == "how are you" {
hub.SayPublic("good thanks!")
}
default:
fmt.Printf("%+v\n", event)
}
}
}