Documentation
¶
Index ¶
- Constants
- func DispatchMsg(f func(event interface{})) func(event interface{})
- func SyncRequest(s *Session, msg proto.Message, out proto.Message) error
- type AcceptSession
- type Acceptor
- func (this_ *Acceptor) CheckPingPong(sess *Session)
- func (this_ *Acceptor) Close()
- func (this_ *Acceptor) GetListener() net.Listener
- func (this_ *Acceptor) OnNormalMsg(session *Session, msg proto.Message)
- func (this_ *Acceptor) OnRPCRequest(session *Session, msg proto.Message) proto.Message
- func (this_ *Acceptor) OnSessionConnected(session *Session)
- func (this_ *Acceptor) OnSessionDisConnected(session *Session, err error)
- func (this_ *Acceptor) SetCallback(ai DispatchInterface)
- func (this_ *Acceptor) StartAccept()
- type AllDoConcurrent
- type CloseError
- type CodeC
- type ConnectError
- type ConnectFailedInterface
- type Connector
- func (this_ *Connector) Close(err error)
- func (this_ *Connector) Connect()
- func (this_ *Connector) DoConcurrent(msgID string) bool
- func (this_ *Connector) GetAddr() string
- func (this_ *Connector) GetSession() *Session
- func (this_ *Connector) OnNormalMsg(s *Session, msg proto.Message)
- func (this_ *Connector) OnRPCRequest(s *Session, msg proto.Message) proto.Message
- func (this_ *Connector) OnSessionConnected(s *Session)
- func (this_ *Connector) OnSessionDisConnected(s *Session, err error)
- func (this_ *Connector) RemoteAddr() string
- func (this_ *Connector) Request(msg proto.Message, resp RPCResponse) (err error)
- func (this_ *Connector) RequestNoError(msg proto.Message, resp RPCResponse)
- func (this_ *Connector) Send(msg proto.Message) (err error)
- func (this_ *Connector) SendNoError(msg proto.Message)
- func (this_ *Connector) SetCallback(ci DispatchInterface)
- func (this_ *Connector) SetDoConcurrent(dc DoConcurrentInterface)
- func (this_ *Connector) SetOnConnectFailed(f func(connector *Connector, err error))
- type ConnectorInfo
- type DefaultDoConcurrent
- type DefaultLogDispatch
- func (this_ *DefaultLogDispatch) OnNormalMsg(s *Session, msg proto.Message)
- func (this_ *DefaultLogDispatch) OnRPCRequest(s *Session, msg proto.Message) proto.Message
- func (this_ *DefaultLogDispatch) OnSessionConnected(s *Session)
- func (this_ *DefaultLogDispatch) OnSessionDisConnected(s *Session, err error)
- type DispatchInterface
- type DoConcurrentInterface
- type ErrServerClosed
- type HookDispatchInterface
- type JSONCodeC
- type MsgIDType
- type Option
- type Packet
- type ProtoCodeC
- type RPCResponse
- type Session
- func (this_ *Session) Close(err error)
- func (this_ *Session) GetLogger() *logger.Logger
- func (this_ *Session) LocalAddr() string
- func (this_ *Session) Next(prevTime time.Time) time.Time
- func (this_ *Session) RemoteAddr() string
- func (this_ *Session) RemoteTcp4IP() string
- func (this_ *Session) Request(msg proto.Message, resp RPCResponse) error
- func (this_ *Session) RequestNoError(msg proto.Message, resp RPCResponse)
- func (this_ *Session) Send(msg proto.Message) error
- func (this_ *Session) SendBytes(msgID string, msg []byte) error
- func (this_ *Session) SendBytesNoError(msgID string, msg []byte)
- func (this_ *Session) SendNoError(msg proto.Message)
- func (this_ *Session) SendPing() error
- func (this_ *Session) SendPong() error
- func (this_ *Session) Start()
- type SessionClosed
- type SessionInterface
- type SessionMap
Constants ¶
View Source
const ( ConnectStateInvalid = iota ConnectStateConnecting ConnectStateConnected ConnectStateDisconnected )
Variables ¶
This section is empty.
Functions ¶
func DispatchMsg ¶
func DispatchMsg(f func(event interface{})) func(event interface{})
Types ¶
type AcceptSession ¶
type AcceptSession struct {
*Session
}
func (*AcceptSession) GetSession ¶
func (this_ *AcceptSession) GetSession() *Session
type Acceptor ¶
func NewAcceptor ¶
func (*Acceptor) CheckPingPong ¶
func (*Acceptor) GetListener ¶
func (*Acceptor) OnNormalMsg ¶
func (*Acceptor) OnRPCRequest ¶
func (*Acceptor) OnSessionConnected ¶
func (*Acceptor) OnSessionDisConnected ¶
func (*Acceptor) SetCallback ¶
func (this_ *Acceptor) SetCallback(ai DispatchInterface)
func (*Acceptor) StartAccept ¶
func (this_ *Acceptor) StartAccept()
type AllDoConcurrent ¶
type AllDoConcurrent struct {
// contains filtered or unexported fields
}
func (*AllDoConcurrent) DoConcurrent ¶
func (this_ *AllDoConcurrent) DoConcurrent(msgID string) bool
func (*AllDoConcurrent) RegisterNotConcurrentMsg ¶
func (this_ *AllDoConcurrent) RegisterNotConcurrentMsg(message proto.Message)
如果注册了 对应的并发消息。不管是 rpc 还是 普通消息 ,那么收到此消息将会在协程池中调用相关函数,
type CloseError ¶
type CloseError struct {
Err error
}
func (*CloseError) Error ¶
func (this_ *CloseError) Error() string
type ConnectError ¶
type ConnectError struct {
Err error
}
func (*ConnectError) Error ¶
func (this_ *ConnectError) Error() string
type ConnectFailedInterface ¶
type Connector ¶
type Connector struct { ConnectTimeout time.Duration ConnectorName string // contains filtered or unexported fields }
func NewConnector ¶
func (*Connector) DoConcurrent ¶
func (*Connector) GetSession ¶
func (*Connector) OnRPCRequest ¶
func (*Connector) OnSessionConnected ¶
func (*Connector) OnSessionDisConnected ¶
func (*Connector) RemoteAddr ¶
func (*Connector) Request ¶
func (this_ *Connector) Request(msg proto.Message, resp RPCResponse) (err error)
func (*Connector) RequestNoError ¶
func (this_ *Connector) RequestNoError(msg proto.Message, resp RPCResponse)
func (*Connector) SendNoError ¶
func (*Connector) SetCallback ¶
func (this_ *Connector) SetCallback(ci DispatchInterface)
func (*Connector) SetDoConcurrent ¶
func (this_ *Connector) SetDoConcurrent(dc DoConcurrentInterface)
func (*Connector) SetOnConnectFailed ¶
type ConnectorInfo ¶
func (*ConnectorInfo) GetSession ¶
func (this_ *ConnectorInfo) GetSession() *Session
type DefaultDoConcurrent ¶
type DefaultDoConcurrent struct {
// contains filtered or unexported fields
}
func (*DefaultDoConcurrent) DoConcurrent ¶
func (this_ *DefaultDoConcurrent) DoConcurrent(msgID string) bool
func (*DefaultDoConcurrent) RegisterConcurrentMsg ¶
func (this_ *DefaultDoConcurrent) RegisterConcurrentMsg(message proto.Message)
如果注册了 对应的并发消息。不管是 rpc 还是 普通消息 ,那么收到此消息将会在协程池中调用相关函数,
type DefaultLogDispatch ¶
type DefaultLogDispatch struct {
// contains filtered or unexported fields
}
func (*DefaultLogDispatch) OnNormalMsg ¶
func (this_ *DefaultLogDispatch) OnNormalMsg(s *Session, msg proto.Message)
func (*DefaultLogDispatch) OnRPCRequest ¶
func (*DefaultLogDispatch) OnSessionConnected ¶
func (this_ *DefaultLogDispatch) OnSessionConnected(s *Session)
func (*DefaultLogDispatch) OnSessionDisConnected ¶
func (this_ *DefaultLogDispatch) OnSessionDisConnected(s *Session, err error)
type DispatchInterface ¶
type DoConcurrentInterface ¶
type ErrServerClosed ¶
type ErrServerClosed string
func (*ErrServerClosed) Error ¶
func (e *ErrServerClosed) Error() string
type HookDispatchInterface ¶
type Option ¶
type Option func(c *Connector)
func WithConnectTimeout ¶
func WithJsonCodeC ¶
func WithJsonCodeC() Option
func WithOpenDebugLog ¶
func WithOpenDebugLog() Option
func WithReconnect ¶
func WithReconnect() Option
type Packet ¶
type Packet struct { Protocol packetProtocol RPCIndex uint32 MsgID string Msg proto.Message Sess *Session }
func (*Packet) GetSession ¶
type ProtoCodeC ¶
type ProtoCodeC struct{}
func (*ProtoCodeC) String ¶
func (this_ *ProtoCodeC) String() string
type RPCResponse ¶
type Session ¶
type Session struct { CodeC sync.Once SessionName string SessionID string Dispatch DispatchInterface // contains filtered or unexported fields }
func NewSession ¶
func (*Session) RemoteAddr ¶
func (*Session) RemoteTcp4IP ¶
func (*Session) RequestNoError ¶
func (this_ *Session) RequestNoError(msg proto.Message, resp RPCResponse)
func (*Session) SendBytesNoError ¶
func (*Session) SendNoError ¶
type SessionClosed ¶
func (*SessionClosed) GetSession ¶
func (this_ *SessionClosed) GetSession() *Session
type SessionInterface ¶
type SessionInterface interface {
GetSession() *Session
}
type SessionMap ¶
type SessionMap struct {
// contains filtered or unexported fields
}
func NewSessionMap ¶
func NewSessionMap(log *logger.Logger) *SessionMap
func (*SessionMap) AddSession ¶
func (this_ *SessionMap) AddSession(s *Session)
func (*SessionMap) DelSession ¶
func (this_ *SessionMap) DelSession(s *Session)
func (*SessionMap) GetSession ¶
func (this_ *SessionMap) GetSession(sessionID string) (*Session, bool)
func (*SessionMap) SendBySessionID ¶
func (this_ *SessionMap) SendBySessionID(sessionID string, msg proto.Message)
func (*SessionMap) SendToAll ¶
func (this_ *SessionMap) SendToAll(msg proto.Message)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.