Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomNumber ¶
func GenerateRandomNumber() int
Types ¶
type AcceptFunc ¶
type AcceptFunc func(data json.RawMessage)
type Notification ¶
type Notification struct {
Notification bool `json:"notification"`
Method string `json:"method"`
Data json.RawMessage `json:"data"`
}
* Notification
{
notification : true,
method : 'chatmessage',
data :
{
foo : 'bar'
}
}
type Peer ¶
type Peer struct {
PeerChans
// contains filtered or unexported fields
}
func (*Peer) Request ¶
func (peer *Peer) Request(method string, data interface{}, success AcceptFunc, reject RejectFunc) chan ResultFuture
type PeerChans ¶
type PeerChans struct {
OnRequest chan RequestData
SendRequest chan SendRequestData
OnNotification chan Notification
OnClose chan transport.TransportErr
OnError chan transport.TransportErr
}
type PeerErr ¶
type PeerErr transport.TransportErr
type RejectFunc ¶
type Request ¶
type Request struct {
Request bool `json:"request"`
Id int `json:"id"`
Method string `json:"method"`
Data json.RawMessage `json:"data"`
}
* Request
{
request : true,
id : 12345678,
method : 'chatmessage',
data :
{
type : 'text',
value : 'Hi there!'
}
}
type RequestData ¶
type RequestData struct {
Accept RespondFunc
Reject RejectFunc
Request Request
}
type RespondFunc ¶
type RespondFunc func(data interface{})
type Response ¶
type Response struct {
Response bool `json:"response"`
Id int `json:"id"`
Ok bool `json:"ok"`
Data json.RawMessage `json:"data"`
}
* Success response
{
response : true,
id : 12345678,
ok : true,
data :
{
foo : 'lalala'
}
}
type ResponseError ¶
type ResponseError struct {
Response bool `json:"response"`
Id int `json:"id"`
Ok bool `json:"ok"`
ErrorCode int `json:"errorCode"`
ErrorReason string `json:"errorReason"`
}
* Error response
{
response : true,
id : 12345678,
ok : false,
errorCode : 123,
errorReason : 'Something failed'
}
type ResultFuture ¶
type ResultFuture struct {
Result json.RawMessage
Err *PeerErr
}
type SendRequestData ¶
type SendRequestData struct {
*Request
*Transcation
}
type Transcation ¶
type Transcation struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.