Advertisement
szymski

Untitled

Sep 18th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. module networking;
  2.  
  3. import std.stdio, std.json;
  4.  
  5. static class Networking {
  6. static:
  7. void delegate(JSONValue data)[string] handlers;
  8.  
  9. void registerHandler(string type, void delegate(JSONValue data) dg) {
  10. handlers[type] = dg;
  11. }
  12.  
  13. void handle(string type, JSONValue data) {
  14. if(auto dg = type in data)
  15. dg(data);
  16. else
  17. writeln("No handler for type: ", type);
  18. }
  19. }
  20.  
  21. static shared this() {
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement