Documentation ¶
Overview ¶
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- type Bootstrap
- func (bootstrap *Bootstrap) Bind(host string, port int) *Bootstrap
- func (bootstrap *Bootstrap) Connect(sraddr string) error
- func (bootstrap *Bootstrap) ConnectUseInterface(sraddr, sladdr string) error
- func (bootstrap *Bootstrap) CreateContext(sraddr string) (Context, error)
- func (bootstrap *Bootstrap) CreateContextUseInterface(sraddr, sladdr string) (Context, error)
- func (bootstrap *Bootstrap) Debug(v ...interface{})
- func (bootstrap *Bootstrap) Debugf(format string, v ...interface{})
- func (bootstrap *Bootstrap) Error(v ...interface{})
- func (bootstrap *Bootstrap) Errorf(format string, v ...interface{})
- func (bootstrap *Bootstrap) Fatal(v ...interface{})
- func (bootstrap *Bootstrap) Fatalf(format string, v ...interface{})
- func (bootstrap *Bootstrap) LogFlush()
- func (bootstrap *Bootstrap) Notice(v ...interface{})
- func (bootstrap *Bootstrap) Noticef(format string, v ...interface{})
- func (bootstrap *Bootstrap) RegisterHandler(fns ...Handler) *Bootstrap
- func (bootstrap *Bootstrap) SetEventListener(eventListener EventListener) *Bootstrap
- func (bootstrap *Bootstrap) SetKeepAlive(keepalive bool) *Bootstrap
- func (bootstrap *Bootstrap) SetReadBufferSize(readBufferSize int) *Bootstrap
- func (bootstrap *Bootstrap) Shutdown()
- func (bootstrap *Bootstrap) Sync()
- func (bootstrap *Bootstrap) Trace(v ...interface{})
- func (bootstrap *Bootstrap) Tracef(format string, v ...interface{})
- func (bootstrap *Bootstrap) Warn(v ...interface{})
- func (bootstrap *Bootstrap) Warnf(format string, v ...interface{})
- type Context
- type DefaultEventListener
- type EventListener
- type Handler
- type Options
- type Serializable
- type SocketAddr
Constants ¶
const ( // VERSION is the current version. VERSION = "1.0.0" // ACCEPT_MIN_SLEEP is the minimum acceptable sleep times on temporary errors. ACCEPT_MIN_SLEEP = 10 * time.Millisecond // ACCEPT_MAX_SLEEP is the maximum acceptable sleep times on temporary errors ACCEPT_MAX_SLEEP = 1 * time.Second // VERSION is the current version. READ_BUFFER_SIZE = 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶
type Bootstrap struct {
// contains filtered or unexported fields
}
Bootstrap 启动器
func (*Bootstrap) ConnectUseInterface ¶
ConnectUseInterface 连接服务器连接地址、端口,使用指定网络接口连接(laddr端口为0使用随机端口)。
func (*Bootstrap) CreateContext ¶
CreateContext 连接服务器连接地址、端口,使用指定网络接口连接(laddr端口为0使用随机端口)。
func (*Bootstrap) CreateContextUseInterface ¶
CreateContextUseInterface 连接服务器连接地址、端口,使用指定网络接口连接(laddr端口为0使用随机端口)。
func (*Bootstrap) Debug ¶
func (bootstrap *Bootstrap) Debug(v ...interface{})
Debug logs a debug statement
func (*Bootstrap) Fatal ¶
func (bootstrap *Bootstrap) Fatal(v ...interface{})
Fatal logs a fatal error
func (*Bootstrap) Notice ¶
func (bootstrap *Bootstrap) Notice(v ...interface{})
Notice logs a notice statement
func (*Bootstrap) RegisterHandler ¶
RegisterHandler 注册连接接收数据时回调执行函数
func (*Bootstrap) SetEventListener ¶
func (bootstrap *Bootstrap) SetEventListener(eventListener EventListener) *Bootstrap
SetEventListener 设置连接的事件监听
func (*Bootstrap) SetKeepAlive ¶
SetKeepAlive 配置连接keepalive,default is false
func (*Bootstrap) SetReadBufferSize ¶
SetReadBufferSize 配置连接读缓存大小。
func (*Bootstrap) Trace ¶
func (bootstrap *Bootstrap) Trace(v ...interface{})
Trace logs a trace statement
type Context ¶
type Context interface { Read(b []byte) (n int, err error) Write(b []byte) (n int, err error) WriteSerialData(s Serializable) (n int, e error) LocalAddr() net.Addr RemoteAddr() net.Addr LocalAddrToSocketAddr() *SocketAddr RemoteAddrToSocketAddr() *SocketAddr UniqueSocketAddr() *SocketAddr ServMode() bool Close() error Closed() bool String() string }
Context the context of connection, like conn channel, not go chan.
type DefaultEventListener ¶
type DefaultEventListener struct { }
func (*DefaultEventListener) OnContextActive ¶
func (listener *DefaultEventListener) OnContextActive(ctx Context)
func (*DefaultEventListener) OnContextClosed ¶
func (listener *DefaultEventListener) OnContextClosed(ctx Context)
func (*DefaultEventListener) OnContextConnect ¶
func (listener *DefaultEventListener) OnContextConnect(ctx Context)
func (*DefaultEventListener) OnContextError ¶
func (listener *DefaultEventListener) OnContextError(ctx Context, err error)
type EventListener ¶
type Serializable ¶
type Serializable interface {
Bytes() []byte
}
type SocketAddr ¶
func AddrToSocketAddr ¶
func AddrToSocketAddr(addr string) SocketAddr
func (*SocketAddr) String ¶
func (sa *SocketAddr) String() string