e0ca139
Branches > client-handling-rewrite > e0ca139 > files
Move aleph server from core to serve ns
Commit: e0ca139c3a88c4a5e775749872cf47c4e07c2f90
Parent: 66ebfc3
2 changed files:
src/net/bowmap/core.clj view file
@@ -1,6 +1,5 @@ (ns net.bowmap.core (:require- [aleph.tcp :as tcp] [manifold.deferred :as d] [manifold.stream :as s] [net.bowmap.client.state :as state]@@ -8,11 +7,10 @@ [net.bowmap.packet-handling :as handle] [net.bowmap.packet.client :as cp :refer [encode-packet]] [net.bowmap.packet.read :as read]- [net.bowmap.packet.server :as sp])+ [net.bowmap.packet.server :as sp]+ [net.bowmap.server :refer [start-server!]]) (:import- [io.netty.bootstrap ServerBootstrap]- [io.netty.buffer ByteBuf Unpooled]- [io.netty.channel ChannelOption]))+ [io.netty.buffer ByteBuf Unpooled])) (defn packet-framer-xf "Transducer that frames bytes from incoming byte arrays and outputs ByteBufs of@@ -87,17 +85,15 @@ (fn [e] (println "Exception in client packets:" e))))) -;; TODO move this into net.bowmap.server :p-(defn start-server! []- (tcp/start-server #'client-handler- {:port 25565- :bootstrap-transform #(ServerBootstrap/.childOption % ChannelOption/TCP_NODELAY true)}))+(defn start-server []+ (start-server! {:handler #'client-handler+ :port 25565})) (defn -main [& _args]- (start-server!)+ (start-server) (println "Server Started")) (comment (require 'dev.grahp.bytebuf)- (def server (start-server!))+ (def server (start-server)) (.close server))src/net/bowmap/server.clj view file
@@ -1,5 +1,13 @@-(ns net.bowmap.server)+(ns net.bowmap.server+ (:require+ [aleph.tcp :as tcp])+ (:import+ [io.netty.bootstrap ServerBootstrap]+ [io.netty.channel ChannelOption])) -;; Use aleph for now and a java.net server later-;; Take the aleph stuff out of core-(defn start-server [& {:keys [handler port]}])+(defn start-server!+ "Starts a TCP server at port 'port', calling 'handler' with each client, with TCP_NODELAY enabled."+ [& {:keys [handler port]}]+ (tcp/start-server handler+ {:port port+ :bootstrap-transform #(ServerBootstrap/.childOption % ChannelOption/TCP_NODELAY true)}))