Compare commits
4 Commits
nmdc-log-s
...
v0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
| f8ac216379 | |||
| 28ad3c8e6a | |||
| 820fa72b77 | |||
| f4b868b0c7 |
2
.hgtags
Normal file
2
.hgtags
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
945ab4b16d05aa084f71bf5da9a3f687e0ec8bbd libnmdc-r1
|
||||||
|
02a360e95480b97ddad83add5db48b2766339a99 nmdc-log-service-1.0.0
|
||||||
@@ -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
|
|
||||||
20
src/libnmdc/__dist/README.txt
Normal file
20
src/libnmdc/__dist/README.txt
Normal 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
|
||||||
38
src/libnmdc/libnmdc_sample.go
Normal file
38
src/libnmdc/libnmdc_sample.go
Normal 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user