Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ws/network.hpp"
- #include <string>
- #include <iostream>
- namespace test {
- using std::string;
- using std::cout;
- using std::endl;
- class server: public ws::server {
- static void onCookies(const ws::client& from, const server& to, const string& content){
- cout << "Cookies have been baked with " << content << endl;
- }
- server(): ws::server {
- bindMessage("Cookies", onCookies);
- }
- void onConnect(const ws::client& c){
- cout << c.Address() << endl;
- }
- void onMessage(const ws::client& from, const string& name, const string& content){
- cout << "Client " << from.Address() << " sent message \"" << name << "\" with content " << content;
- if(name == "Stop"){
- cout << "NOOO DON'T KILL ME" << endl;
- Stop();
- }
- }
- };
- }
- int main(){
- test::server s(27015);
- s.Start();
- while(s.Running())
- s.Think();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement