作者 yangfu

ws

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