first commit
This commit is contained in:
28
pkg/websocket/client/service/method.go
Normal file
28
pkg/websocket/client/service/method.go
Normal file
@ -0,0 +1,28 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var (
|
||||
typeOfBytes = reflect.TypeOf(([]byte)(nil))
|
||||
typeOfSession = reflect.TypeOf(NewSession(nil))
|
||||
)
|
||||
|
||||
// 方法检测
|
||||
func isHandlerMethod(method reflect.Method) bool {
|
||||
mt := method.Type
|
||||
if method.PkgPath != "" {
|
||||
return false
|
||||
}
|
||||
if mt.NumIn() != 3 {
|
||||
return false
|
||||
}
|
||||
if t1 := mt.In(1); t1.Kind() != reflect.Ptr || t1 != typeOfSession {
|
||||
return false
|
||||
}
|
||||
if mt.In(2).Kind() != reflect.Ptr && mt.In(2) != typeOfBytes {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
Reference in New Issue
Block a user