-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
25 lines (24 loc) · 992 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { Plugin, WebSocketConnection, WebSocketServer, Router, View, Request, Response } from "unturned2-panel"
import * as path from "path";
export default class ExamplePlugin implements Plugin {
get name () { return "fr34kyn01535.ExamplePlugin"; }
load() { console.log("Example plugin loaded"); }
registerRoutes(router: Router) {
router.get('/ping' ,function (req: Request, res: Response) {
if(req.user){
return res.send("hello "+req.user.userName);
}else{
return res.send("i dont know you");
}
});
}
getViews() : View[] {
return [ new View("test", path.join(path.resolve(__dirname,"./Views/") ),"Test","gear") ];
}
handleWSConnected(socket: WebSocketConnection) {
socket.on("pingsocket",function(){
socket.emit("pongsocket","from my handler");
WebSocketServer.broadcast("pungsocket","from brodacast handler");
});
}
}