本文整理匯總了Golang中github.com/nyxtom/broadcast/server.ProtocolClient.RequestErrorChan方法的典型用法代碼示例。如果您正苦於以下問題:Golang ProtocolClient.RequestErrorChan方法的具體用法?Golang ProtocolClient.RequestErrorChan怎麽用?Golang ProtocolClient.RequestErrorChan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nyxtom/broadcast/server.ProtocolClient
的用法示例。
在下文中一共展示了ProtocolClient.RequestErrorChan方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RunClient
func (p *LineProtocol) RunClient(client server.ProtocolClient) {
c, ok := client.(*LineProtocolClient)
if !ok {
client.WriteError(errInvalidProtocol)
client.Close()
return
}
defer func() {
if e := recover(); e != nil {
buf := make([]byte, 4096)
n := runtime.Stack(buf, false)
buf = buf[0:n]
p.ctx.Events <- server.BroadcastEvent{"fatal", "client run panic", errors.New(fmt.Sprintf("%v", e)), buf}
}
c.Close()
return
}()
reqErr := client.RequestErrorChan()
for {
data, err := c.readBulk()
if err != nil {
if err != io.EOF {
p.ctx.Events <- server.BroadcastEvent{"error", "read error", err, nil}
}
return
}
err = p.handleData(data, c, reqErr)
if err != nil {
if err == errQuit {
return
} else {
p.ctx.Events <- server.BroadcastEvent{"error", "accept error", err, nil}
c.WriteError(err)
c.Flush()
}
}
}
}
示例2: RunClient
func (p *RedisProtocol) RunClient(client server.ProtocolClient) {
// defer panics to the loggable event routine
defer func() {
if e := recover(); e != nil {
buf := make([]byte, 4096)
n := runtime.Stack(buf, false)
buf = buf[0:n]
p.ctx.Events <- server.BroadcastEvent{"fatal", "client run panic", errors.New(fmt.Sprintf("%v", e)), buf}
}
client.Close()
return
}()
reqErr := client.RequestErrorChan()
for {
data, err := client.ReadBulkPayload()
if err != nil {
if err != io.EOF {
p.ctx.Events <- server.BroadcastEvent{"error", "read error", err, nil}
}
return
}
err = p.handleData(data, client, reqErr)
if err != nil {
if err == errQuit {
client.WriteString("OK")
client.Flush()
return
} else {
p.ctx.Events <- server.BroadcastEvent{"error", "accept error", err, nil}
client.WriteError(err)
client.Flush()
}
}
}
}