goworld: github.com/xiaonanln/goworld/engine/proto Index | Files

package proto

import "github.com/xiaonanln/goworld/engine/proto"

Index

Package Files

GoWorldConnection.go proto.go

Constants

const (
    // MT_INVALID is the invalid message type
    MT_INVALID = iota
    // MT_SET_GAME_ID is a message type for game
    MT_SET_GAME_ID
    // MT_SET_GATE_ID is a message type for gate
    MT_SET_GATE_ID
    // MT_NOTIFY_CREATE_ENTITY is a message type for creating entities
    MT_NOTIFY_CREATE_ENTITY
    // MT_NOTIFY_DESTROY_ENTITY is a message type for destroying entities
    MT_NOTIFY_DESTROY_ENTITY
    // MT_DECLARE_SERVICE is a message type for declaring services
    MT_DECLARE_SERVICE
    // MT_UNDECLARE_SERVICE is a message type for undeclaring services
    MT_UNDECLARE_SERVICE
    // MT_CALL_ENTITY_METHOD is a message type for calling entity methods
    MT_CALL_ENTITY_METHOD
    // MT_CREATE_ENTITY_ANYWHERE is a message type for creating entities
    MT_CREATE_ENTITY_ANYWHERE
    // MT_LOAD_ENTITY_ANYWHERE is a message type loading entities
    MT_LOAD_ENTITY_ANYWHERE
    // MT_NOTIFY_CLIENT_CONNECTED is a message type for clients
    MT_NOTIFY_CLIENT_CONNECTED
    // MT_NOTIFY_CLIENT_DISCONNECTED is a message type for clients
    MT_NOTIFY_CLIENT_DISCONNECTED
    // MT_CALL_ENTITY_METHOD_FROM_CLIENT is a message type for clients
    MT_CALL_ENTITY_METHOD_FROM_CLIENT
    // MT_SYNC_POSITION_YAW_FROM_CLIENT is a message type for clients
    MT_SYNC_POSITION_YAW_FROM_CLIENT
    // MT_NOTIFY_ALL_GAMES_CONNECTED is a message type to notify all games connected
    MT_NOTIFY_ALL_GAMES_CONNECTED
    // MT_NOTIFY_GATE_DISCONNECTED is a message type to notify gate disconnected
    MT_NOTIFY_GATE_DISCONNECTED
    // MT_START_FREEZE_GAME is a message type for hot swapping
    MT_START_FREEZE_GAME
    // MT_START_FREEZE_GAME_ACK is a message type for hot swapping
    MT_START_FREEZE_GAME_ACK

    // MT_MIGRATE_REQUEST is a message type for entity migrations
    MT_MIGRATE_REQUEST
    // MT_REAL_MIGRATE is a message type for entity migrations
    MT_REAL_MIGRATE
)
const (
    // MT_GATE_SERVICE_MSG_TYPE_START is the first message types that should be handled by GateService
    MT_GATE_SERVICE_MSG_TYPE_START = 1000 + iota
    // MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_START is the first message type that should be redirected to client proxy
    MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_START
    // MT_CREATE_ENTITY_ON_CLIENT message type
    MT_CREATE_ENTITY_ON_CLIENT
    // MT_DESTROY_ENTITY_ON_CLIENT message type
    MT_DESTROY_ENTITY_ON_CLIENT
    // MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT message type
    MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT
    // MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT message type
    MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT
    // MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT message type
    MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT
    // MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT message type
    MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT
    // MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT message type
    MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT
    // MT_CALL_ENTITY_METHOD_ON_CLIENT message type
    MT_CALL_ENTITY_METHOD_ON_CLIENT
    // MT_SET_CLIENTPROXY_FILTER_PROP message type
    MT_SET_CLIENTPROXY_FILTER_PROP
    // MT_CLEAR_CLIENTPROXY_FILTER_PROPS message type
    MT_CLEAR_CLIENTPROXY_FILTER_PROPS
    // MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_STOP message type
    MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_STOP = 1499
)
const (
    // MT_CALL_FILTERED_CLIENTS message type: messages to be processed by GateService from Dispatcher, but not redirected to clients
    MT_CALL_FILTERED_CLIENTS = 1501 + iota
    // MT_SYNC_POSITION_YAW_ON_CLIENTS message type
    MT_SYNC_POSITION_YAW_ON_CLIENTS
    // MT_GATE_SERVICE_MSG_TYPE_STOP message type
    MT_GATE_SERVICE_MSG_TYPE_STOP = 1999
)
const (
    // MT_SET_CLIENT_CLIENTID message is sent to client to set its clientid
    MT_SET_CLIENT_CLIENTID = 2001 + iota
    MT_UDP_SYNC_CONN_NOTIFY_CLIENTID
    MT_UDP_SYNC_CONN_NOTIFY_CLIENTID_ACK
    // MT_HEARTBEAT_FROM_CLIENT is sent by client to notify the gate server that the client is alive
    MT_HEARTBEAT_FROM_CLIENT
)

Messages types that is sent directly between Gate & Client

const (
    // SYNC_INFO_SIZE_PER_ENTITY is the size of sync info per entity
    SYNC_INFO_SIZE_PER_ENTITY = 16
    UDP_SYNC_PACKET_SIZE      = common.ENTITYID_LENGTH + SYNC_INFO_SIZE_PER_ENTITY
)

type EntitySyncInfo Uses

type EntitySyncInfo struct {
    X, Y, Z float32
    Yaw     float32
}

EntitySyncInfo defines fields of entity sync info

type GoWorldConnection Uses

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

GoWorldConnection is the network protocol implementation of GoWorld components (dispatcher, gate, game)

func NewGoWorldConnection Uses

func NewGoWorldConnection(conn netutil.Connection, compressConnection bool, compressFormat string) *GoWorldConnection

NewGoWorldConnection creates a GoWorldConnection using network connection

func (*GoWorldConnection) Close Uses

func (gwc *GoWorldConnection) Close() error

Close this connection

func (*GoWorldConnection) Flush Uses

func (gwc *GoWorldConnection) Flush(reason string) error

Flush connection writes

func (*GoWorldConnection) IsClosed Uses

func (gwc *GoWorldConnection) IsClosed() bool

IsClosed returns if the connection is closed

func (*GoWorldConnection) LocalAddr Uses

func (gwc *GoWorldConnection) LocalAddr() net.Addr

LocalAddr returns the local address

func (*GoWorldConnection) Recv Uses

func (gwc *GoWorldConnection) Recv(msgtype *MsgType) (*netutil.Packet, error)

Recv receives the next packet and retrive the message type

func (*GoWorldConnection) RemoteAddr Uses

func (gwc *GoWorldConnection) RemoteAddr() net.Addr

RemoteAddr returns the remote address

func (*GoWorldConnection) SendCallEntityMethod Uses

func (gwc *GoWorldConnection) SendCallEntityMethod(id common.EntityID, method string, args []interface{}) error

SendCallEntityMethod sends MT_CALL_ENTITY_METHOD message

func (*GoWorldConnection) SendCallEntityMethodFromClient Uses

func (gwc *GoWorldConnection) SendCallEntityMethodFromClient(id common.EntityID, method string, args []interface{}) error

SendCallEntityMethodFromClient sends MT_CALL_ENTITY_METHOD_FROM_CLIENT message

func (*GoWorldConnection) SendCallEntityMethodOnClient Uses

func (gwc *GoWorldConnection) SendCallEntityMethodOnClient(gid uint16, clientid common.ClientID, entityID common.EntityID, method string, args []interface{}) (err error)

SendCallEntityMethodOnClient sends MT_CALL_ENTITY_METHOD_ON_CLIENT message

func (*GoWorldConnection) SendCallFilterClientProxies Uses

func (gwc *GoWorldConnection) SendCallFilterClientProxies(key string, val string, method string, args []interface{}) (err error)

SendCallFilterClientProxies sends MT_CALL_FILTERED_CLIENTS message

func (*GoWorldConnection) SendClearClientFilterProp Uses

func (gwc *GoWorldConnection) SendClearClientFilterProp(gid uint16, clientid common.ClientID) (err error)

SendClearClientFilterProp sends MT_CLEAR_CLIENTPROXY_FILTER_PROPS message

func (*GoWorldConnection) SendCreateEntityAnywhere Uses

func (gwc *GoWorldConnection) SendCreateEntityAnywhere(typeName string, data map[string]interface{}) error

SendCreateEntityAnywhere sends MT_CREATE_ENTITY_ANYWHERE message

func (*GoWorldConnection) SendCreateEntityOnClient Uses

func (gwc *GoWorldConnection) SendCreateEntityOnClient(gid uint16, clientid common.ClientID, typeName string, entityid common.EntityID,
    isPlayer bool, clientData map[string]interface{}, x, y, z float32, yaw float32) error

SendCreateEntityOnClient sends MT_CREATE_ENTITY_ON_CLIENT message

func (*GoWorldConnection) SendDeclareService Uses

func (gwc *GoWorldConnection) SendDeclareService(id common.EntityID, serviceName string) error

SendDeclareService sends MT_DECLARE_SERVICE message

func (*GoWorldConnection) SendDestroyEntityOnClient Uses

func (gwc *GoWorldConnection) SendDestroyEntityOnClient(gid uint16, clientid common.ClientID, typeName string, entityid common.EntityID) error

SendDestroyEntityOnClient sends MT_DESTROY_ENTITY_ON_CLIENT message

func (*GoWorldConnection) SendLoadEntityAnywhere Uses

func (gwc *GoWorldConnection) SendLoadEntityAnywhere(typeName string, entityID common.EntityID) error

SendLoadEntityAnywhere sends MT_LOAD_ENTITY_ANYWHERE message

func (*GoWorldConnection) SendMigrateRequest Uses

func (gwc *GoWorldConnection) SendMigrateRequest(spaceID common.EntityID, entityID common.EntityID) error

SendMigrateRequest sends MT_MIGRATE_REQUEST message

func (*GoWorldConnection) SendNotifyClientConnected Uses

func (gwc *GoWorldConnection) SendNotifyClientConnected(id common.ClientID) error

SendNotifyClientConnected sends MT_NOTIFY_CLIENT_CONNECTED message

func (*GoWorldConnection) SendNotifyClientDisconnected Uses

func (gwc *GoWorldConnection) SendNotifyClientDisconnected(id common.ClientID) error

SendNotifyClientDisconnected sends MT_NOTIFY_CLIENT_DISCONNECTED message

func (*GoWorldConnection) SendNotifyCreateEntity Uses

func (gwc *GoWorldConnection) SendNotifyCreateEntity(id common.EntityID) error

SendNotifyCreateEntity sends MT_NOTIFY_CREATE_ENTITY message

func (*GoWorldConnection) SendNotifyDestroyEntity Uses

func (gwc *GoWorldConnection) SendNotifyDestroyEntity(id common.EntityID) error

SendNotifyDestroyEntity sends MT_NOTIFY_DESTROY_ENTITY message

func (*GoWorldConnection) SendNotifyListAttrAppendOnClient Uses

func (gwc *GoWorldConnection) SendNotifyListAttrAppendOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, val interface{}) error

SendNotifyListAttrAppendOnClient sends MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT message

func (*GoWorldConnection) SendNotifyListAttrChangeOnClient Uses

func (gwc *GoWorldConnection) SendNotifyListAttrChangeOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, index uint32, val interface{}) error

SendNotifyListAttrChangeOnClient sends MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT message

func (*GoWorldConnection) SendNotifyListAttrPopOnClient Uses

func (gwc *GoWorldConnection) SendNotifyListAttrPopOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}) error

SendNotifyListAttrPopOnClient sends MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT message

func (*GoWorldConnection) SendNotifyMapAttrChangeOnClient Uses

func (gwc *GoWorldConnection) SendNotifyMapAttrChangeOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, key string, val interface{}) error

SendNotifyMapAttrChangeOnClient sends MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT message

func (*GoWorldConnection) SendNotifyMapAttrDelOnClient Uses

func (gwc *GoWorldConnection) SendNotifyMapAttrDelOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, key string) error

SendNotifyMapAttrDelOnClient sends MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT message

func (*GoWorldConnection) SendPacket Uses

func (gwc *GoWorldConnection) SendPacket(packet *netutil.Packet) error

SendPacket send a packet to remote

func (*GoWorldConnection) SendPacketRelease Uses

func (gwc *GoWorldConnection) SendPacketRelease(packet *netutil.Packet) error

SendPacketRelease send a packet to remote and then release the packet

func (*GoWorldConnection) SendRealMigrate Uses

func (gwc *GoWorldConnection) SendRealMigrate(eid common.EntityID, targetGame uint16, targetSpace common.EntityID, x, y, z float32,
    typeName string, migrateData map[string]interface{}, timerData []byte, clientid common.ClientID, clientsrv uint16) error

SendRealMigrate sends MT_REAL_MIGRATE message

func (*GoWorldConnection) SendSetClientFilterProp Uses

func (gwc *GoWorldConnection) SendSetClientFilterProp(gid uint16, clientid common.ClientID, key, val string) (err error)

SendSetClientFilterProp sends MT_SET_CLIENTPROXY_FILTER_PROP message

func (*GoWorldConnection) SendSetGameID Uses

func (gwc *GoWorldConnection) SendSetGameID(id uint16, isReconnect bool, isRestore bool) error

SendSetGameID sends MT_SET_GAME_ID message

func (*GoWorldConnection) SendSetGateID Uses

func (gwc *GoWorldConnection) SendSetGateID(id uint16) error

SendSetGateID sends MT_SET_GATE_ID message

func (*GoWorldConnection) SendStartFreezeGame Uses

func (gwc *GoWorldConnection) SendStartFreezeGame(gameid uint16) error

SendStartFreezeGame sends MT_START_FREEZE_GAME message

func (*GoWorldConnection) SendSyncPositionYawFromClient Uses

func (gwc *GoWorldConnection) SendSyncPositionYawFromClient(entityID common.EntityID, x, y, z float32, yaw float32) error

SendSyncPositionYawFromClient sends MT_SYNC_POSITION_YAW_FROM_CLIENT message

func (*GoWorldConnection) SetAutoFlush Uses

func (gwc *GoWorldConnection) SetAutoFlush(interval time.Duration)

SetAutoFlush starts a goroutine to flush connection writes at some specified interval

func (*GoWorldConnection) SetHeartbeatFromClient Uses

func (gwc *GoWorldConnection) SetHeartbeatFromClient() error

func (*GoWorldConnection) SetRecvDeadline Uses

func (gwc *GoWorldConnection) SetRecvDeadline(deadline time.Time) error

SetRecvDeadline set receive deadline

func (*GoWorldConnection) String Uses

func (gwc *GoWorldConnection) String() string

type MsgType Uses

type MsgType uint16

MsgType is the type of message types

Package proto imports 9 packages (graph) and is imported by 5 packages. Updated 2017-11-06. Refresh now. Tools for package owners.