let count=0;
let users=[];
function onOpen(ctx){
count++;
if(!users.find(x=>x.Id==ctx.Id))users.push(ctx);
console.log("open", ctx.Id, count, users.length);
}
function onMsg(ctx, msg){
console.log("msg", msg);
api.sendTo(users, msg);
}
function onClose(ctx, err){
console.log("close",ctx.Id);
}
//ctx
type Ctx struct {
Conn *websocket.Conn
Id string
Errs int32
Info interface{}
}
//api
map[string]interface{}{
"sendTo": SendTo,
"ctxs": &ctxs,
"OS": &kgo.KOS,
"FS": &kgo.KFile,
"Date": &kgo.KTime,
"Encode": &kgo.KEncr,
"Convert": &kgo.KConv,
"Array": &kgo.KArr,
"String": &kgo.KStr,
"Number": &kgo.KNum,
"getFile": getFileStr,
"saveFile": saveFile,
"httpGet": httpGet,
"httpPost": httpPost,
}