...

Package dm

import "github.com/Diarkis/diarkis/dm"
Overview
Index

Overview ▾

func ExposeCommands

func ExposeCommands()

func SetCustomDisconnectCmdOnUserDiscard

func SetCustomDisconnectCmdOnUserDiscard(ver uint8, cmd uint16)

SetCustomDisconnectCmdOnUserDiscard sets ver and cmd for call disconnect when user is discarded autmatically.

func SetOnUserDiscardDisconnectBytes

func SetOnUserDiscardDisconnectBytes(fn func(*user.User) []byte)

SetOnUserDiscardDisconnectBytes defines a custom function to create call disconnect message bytes on user discard.

func Setup

func Setup()

Setup must be called in the server main function to setup dm module before diarkis.Start

type Call

Call direct message channel for 2 users

type Call struct {
    OnReceive    func(myUID string, peerUID string, message []byte)
    OnDisconnect func(myUID string, peerUID string)
    // contains filtered or unexported fields
}

func GetCallByPeerID

func GetCallByPeerID(uid string) *Call

GetCallByPeerID returns a call channel by the peer user ID

func NewCall

func NewCall(myUID string, uid string, callback func(error)) *Call

NewCall creates a new call channel with a given user to send and receive direct messages

func (*Call) Connect

func (c *Call) Connect(uid string, done func(error))

Connect starts a new call channel

func (*Call) Disconnect

func (c *Call) Disconnect(ver uint8, cmd uint16, message []byte)

Disconnect disconnects direct message call channel and sends a message to the peer

func (*Call) RSend

func (c *Call) RSend(ver uint8, cmd uint16, message []byte)

Send sends a reliable (UDP only) direct message to the peer

func (*Call) Send

func (c *Call) Send(ver uint8, cmd uint16, message []byte)

Send sends an unreliable (UDP only) direct message to the peer