realtime

package
v0.0.0-...-084a6c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Realtime

type Realtime struct {
	// contains filtered or unexported fields
}

Realtime controller

func NewRealtime

func NewRealtime(kuzzle types.IKuzzle) *Realtime

NewRealtime instanciates a new realtime controller

func (*Realtime) Count

func (r *Realtime) Count(roomID string, options types.QueryOptions) (int, error)

Count returns the number of other subscriptions on that room.

func (*Realtime) Publish

func (r *Realtime) Publish(index string, collection string, body json.RawMessage, options types.QueryOptions) error

Publish sends a real-time message to Kuzzle

func (*Realtime) Subscribe

func (r *Realtime) Subscribe(index, collection string, filters json.RawMessage, cb chan<- types.NotificationResult, options types.RoomOptions) (*types.SubscribeResult, error)

Subscribe permits to join a previously created subscription

Example
package main

import (
	"encoding/json"

	"github.com/kuzzleio/sdk-go/internal"
	"github.com/kuzzleio/sdk-go/kuzzle"
	"github.com/kuzzleio/sdk-go/realtime"
	"github.com/kuzzleio/sdk-go/state"
	"github.com/kuzzleio/sdk-go/types"
)

func main() {
	c := &internal.MockedConnection{
		MockSend: func(query []byte, options types.QueryOptions) *types.KuzzleResponse {
			roomRaw := []byte(`{"requestId": "rqid", "channel": "foo", "roomId": "42"}`)
			return &types.KuzzleResponse{Result: roomRaw}
		},
	}
	k, _ := kuzzle.NewKuzzle(c, nil)
	nr := realtime.NewRealtime(k)
	c.SetState(state.Connected)

	notifChan := make(chan<- types.NotificationResult)
	nr.Subscribe("collection", "index", json.RawMessage(""), notifChan, nil)
}
Output:

func (*Realtime) Unsubscribe

func (r *Realtime) Unsubscribe(roomID string, options types.QueryOptions) error

Unsubscribe instructs Kuzzle to detach you from its subscribers for the given room

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL