nostr package, readme updates accordingly, matching example program (#14)

This commit is contained in:
BitcoinCoderBob
2022-10-12 16:24:30 -04:00
committed by GitHub
parent e47c80a63d
commit 9549c3624a
14 changed files with 102 additions and 9 deletions

View File

@@ -1,33 +0,0 @@
package nostr
import (
"github.com/gorilla/websocket"
"sync"
)
type Connection struct {
socket *websocket.Conn
mutex sync.Mutex
}
func NewConnection(socket *websocket.Conn) *Connection {
return &Connection{
socket: socket,
}
}
func (c *Connection) WriteJSON(v interface{}) error {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.socket.WriteJSON(v)
}
func (c *Connection) WriteMessage(messageType int, data []byte) error {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.socket.WriteMessage(messageType, data)
}
func (c *Connection) Close() error {
return c.socket.Close()
}