本文整理汇总了Golang中push-server/buffpool.BuffPool.GetService方法的典型用法代码示例。如果您正苦于以下问题:Golang BuffPool.GetService方法的具体用法?Golang BuffPool.GetService怎么用?Golang BuffPool.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类push-server/buffpool.BuffPool
的用法示例。
在下文中一共展示了BuffPool.GetService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sendToService
func (this *DispatcherOutComponent) sendToService(msg *protocol.Message, buffPool *buffpool.BuffPool) (*net.Conn, error) {
if msg == nil || buffPool == nil {
err := errors.New("DispatcherOutComponent.sendToService() Error: invalid argument")
fmt.Println(err.Error())
return nil, err
}
var conn *net.Conn
if msg.DestUuid == P_UID {
conn = buffPool.GetService(msg.Number)
} else {
conn = buffPool.QueryService(msg.Number, msg.DestUuid)
if conn == nil {
conn = buffPool.GetService(msg.Number)
}
}
if conn == nil {
err := errors.New("DispatcherOutComponent.sendToService() Error: can not get a server connection from buffpool")
fmt.Println(err.Error())
return nil, err
}
err := this.sendMessage(msg, conn)
if err != nil {
err = errors.New("DispatcherOutComponent.sendToService() Error: can not send message to server's connection")
fmt.Println(err.Error())
return conn, err
}
return conn, nil
}
示例2: checkAccountServer
func (this *RegisterComponent) checkAccountServer(buffPool *buffpool.BuffPool, message *protocol.Message, conn *net.Conn) bool {
if buffPool == nil || message == nil || conn == nil {
fmt.Println("RegisterComponent checkAccountServer() Error: invalid argument")
return false
}
connService := buffPool.GetService(protocol.N_ACCOUNT_SYS)
if connService == nil {
fmt.Println("RegisterComponent checkAccountServer() Error: can not get the account_sys server")
response, _ := protocol.NewMessage(protocol.VERSION, protoocl.MT_ERROR, protocol.PT_PUSHSERVER, message.Token, message.Number, 0, P_UID,
message.UserUuid, 0, nil)
err := sendResponse(conn, response)
if err != nil {
err = fmt.Errorf("RegisterComponent checkAccountServer() Error:%v", err)
fmt.Println(err.Error())
}
return false
}
return true
}
示例3: sendToService2
func (this *DispatcherOutComponent) sendToService2(msg *protocol.Message, forward bool, buffPool *buffpool.BuffPool) (*net.Conn, error) {
if msg == nil || buffPool == nil {
err := errors.New("DispatcherOutComponent.sendToService() Error: invalid argument")
fmt.Println(err.Error())
return nil, err
}
var conn *net.Conn
if msg.DestUuid == P_UID {
conn = buffPool.GetService(msg.Number)
} else {
conn = buffPool.QueryService(msg.Number, msg.DestUuid)
if conn == nil && forward && GetRunWithSnode().Flag {
buf, err := msg.Encode()
if err != nil {
fmt.Println(err)
return nil, err
}
snode_component.GetNodeComponent().Forward(stree_define.FORWARD, msg.DestUuid, msg.DeviceId, buf)
return nil, nil
}
}
if conn == nil {
err := errors.New("DispatcherOutComponent.sendToService() Error: can not find dest server")
fmt.Println(err.Error())
return nil, err
}
err := this.sendMessage(msg, conn)
if err != nil {
err = errors.New("DispatcherOutComponent.sendToService() Error: can not send message to server's connection")
fmt.Println(err.Error())
return conn, err
}
if msg.MsgType == protocol.MT_PUBLISH {
fmt.Println("\n", time.Now().String(), "MT_PUBLISH: sendToService2 Directly OK", "\n")
}
return conn, nil
}