作者 yangfu

ws

... ... @@ -16,3 +16,8 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5"
source_host ="http://192.168.139.131:8080/"
source_virtual_path=file/ab
source_path =/home/tiptok/www/ab
#网易云信 IM
net_im_base_url ="https://api.netease.im/nimserver"
net_im_app_secret ="a8d231f5c13a"
net_im_app_key ="9c5410602597a7fe367aeeebd8210262"
\ No newline at end of file
... ...
package v1
import (
"ability/controllers"
)
type WebSocketController struct {
controllers.BaseController
}
... ...
... ... @@ -5,6 +5,7 @@ go 1.12
require (
github.com/astaxie/beego v1.10.0
github.com/go-sql-driver/mysql v1.4.1
github.com/gorilla/websocket v1.4.1
github.com/prometheus/client_golang v1.1.0
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1
... ...
... ... @@ -12,6 +12,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/redis"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/websocket"
"time"
)
... ... @@ -46,6 +47,7 @@ func init() {
//IsUseSsl:true,
})
im.InitImClient(beego.AppConfig.String("net_im_base_url"),beego.AppConfig.String("net_im_app_key"),beego.AppConfig.String("net_im_app_secret"))
websocket.InitWebsocketConnmgrs(10)
}
func main() {
... ...
package protocol
/*WsLogin */
type WsLoginRequest struct {
Uid int64
AppId int
}
type WsLoginResponse struct {
}
... ...
... ... @@ -2,8 +2,10 @@ package routers
import (
"ability/controllers/v1"
"ability/services/websocket"
"github.com/astaxie/beego"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
)
var nsV1 *beego.Namespace
... ... @@ -17,4 +19,5 @@ func init() {
beego.AddNamespace(nsV1)
beego.SetStaticPath("/file/ab", beego.AppConfig.String("source_path"))
beego.Handler("/metrics", promhttp.Handler())
beego.Handler("/upgrage",http.HandlerFunc(websocket.Upgrage))
}
... ...