本文整理汇总了Golang中github.com/antongulenko/RTP/protocols.Server类的典型用法代码示例。如果您正苦于以下问题:Golang Server类的具体用法?Golang Server怎么用?Golang Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Server类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ConfigureHeartbeat
func (client *Client) ConfigureHeartbeat(receiver *protocols.Server, token int64, timeout time.Duration) error {
packet := ConfigureHeartbeatPacket{
Token: token,
TargetServer: receiver.LocalAddr().String(),
Timeout: timeout,
}
reply, err := client.SendRequest(codeConfigureHeartbeat, packet)
if err != nil {
return err
}
return client.CheckReply(reply)
}
开发者ID:antongulenko,项目名称:RTP,代码行数:12,代码来源:protocol.go
示例2: RegisterServer
func RegisterServer(server *protocols.Server) (*LoadStats, error) {
if err := server.Protocol().CheckIncludesFragment(Protocol.Name()); err != nil {
return nil, err
}
stats := &LoadStats{
server: server,
Received: stats.NewStats("Received"),
Missed: stats.NewStats("Missed"),
}
err := server.RegisterHandlers(protocols.ServerHandlerMap{
codeLoad: stats.handleLoad,
})
if err != nil {
return nil, err
}
return stats, nil
}
开发者ID:antongulenko,项目名称:RTP,代码行数:17,代码来源:server.go
示例3: startLoadClient
func startLoadClient() (port int) {
port = start_rtp_port
var server *protocols.Server
var stats *load.LoadStats
for {
var err error
server, err = protocols.NewServer(net.JoinHostPort(rtp_ip, strconv.Itoa(port)), load.MiniProtocol)
if err != nil {
log.Printf("Failed to start Load server on port %v: %v", port, err)
port += 2
continue
}
stats, err = load.RegisterServer(server)
if err != nil {
log.Printf("Failed to register Load server on port %v: %v", port, err)
port += 2
continue
}
if print_load_packets {
stats.Handler = func(packet *load.LoadPacket) {
packet.PrintReceived()
}
}
break
}
tasks.AddNamed("client", server)
go func() {
for err := range server.Errors() {
log.Println("Error receiving Load:", err)
}
}()
log.Printf("Listening on %v UDP port %v for Load\n", rtp_ip, port)
statistics = append(statistics, stats.Received)
statistics = append(statistics, stats.Missed)
return
}
开发者ID:antongulenko,项目名称:RTP,代码行数:37,代码来源:main.go
示例4: RegisterServerHandler
func RegisterServerHandler(server *protocols.Server, handler HeartbeatServerHandler) error {
if err := server.Protocol().CheckIncludesFragment(Protocol.Name()); err != nil {
return err
}
return server.RegisterHandlers(protocols.ServerHandlerMap{
codeHeartbeat: func(packet *protocols.Packet) *protocols.Packet {
val := packet.Val
if beat, ok := val.(*HeartbeatPacket); ok {
handler.HeartbeatReceived(beat)
} else {
server.LogError(fmt.Errorf("Heartbeat received with wrong payload: (%T) %v", val, val))
}
return nil
},
})
}
开发者ID:antongulenko,项目名称:RTP,代码行数:16,代码来源:server.go
示例5: printServerErrors
func printServerErrors(servername string, server *protocols.Server) {
for err := range server.Errors() {
log.Println(servername + " error: " + err.Error())
}
}
开发者ID:antongulenko,项目名称:RTP,代码行数:5,代码来源:main.go
示例6: printErrors
func printErrors(server *protocols.Server) {
for err := range server.Errors() {
log.Println("Server error: " + err.Error())
}
}
开发者ID:antongulenko,项目名称:RTP,代码行数:5,代码来源:main.go
注:本文中的github.com/antongulenko/RTP/protocols.Server类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论