多客服系统 实现一对一私聊 上下线通知
package controllers
import (
"github.com/astaxie/beego/orm"
"github.com/gorilla/websocket"
"imservice/models"
"log"
"net/http"
)
type Service struct {
WebsiteName string `json:"website_name,omitempty"`
WebsiteId int `json:"website_id,omitempty"`
ServiceId int `json:"service_id,omitempty"`
WebsiteLogo string `json:"website_logo,omitempty"`
NiceName string `json:"nice_name,omitempty"`
Mobile string `json:"mobile,omitempty"`
FixedMobile string `json:"fixed_mobile,omitempty"`
Token string `json:"token,omitempty"`
Ws *websocket.Conn
}
type Cust struct {
NiceName string `json:"nick_name,omitempty"`
CustId int64 `json:"cust_id,omitempty"`
Token string `json:"token,omitempty"`
Ws *websocket.Conn
}
var listService = make(map[int]Service)
var listServiceWs = make(map[*websocket.Conn]int)
var listCust = make(map[int64]Cust)
var listCustWs = make(map[*websocket.Conn]int64)
type ToService struct {
Type string `json:"type,omitempty"`
ServiceId int `json:"service_id,omitempty"`
Messgae interface{
} `json:"message,omitempty"`
NiceName string `json:"nick_name,omitempty"`
CustId int64 `json:"cust_id,omitempty"`
}
var ServiceChannal = make(chan ToService)
type ToCust struct {
Type string `json:"type,omitempty"`
CustId int64 `json:"cust_id,omitempty"`