Created
December 22, 2015 08:20
-
-
Save anonymous/52e00d2e9e7e9c183411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gpsservices.autolink2 | |
(:require [clojure.core.async :refer [timeout buffer alts!! alts! close! onto-chan go go-loop chan <! >! >!! <!! thread]] | |
[manifold.deferred :as d] | |
[manifold.stream :as s] | |
[clojure.edn :as edn] | |
[aleph.tcp :as tcp] | |
[gloss.core :as gloss] | |
[gloss.io :as io])) | |
(gloss/defcodec utf-codec (gloss/string :utf-8)) | |
(defn m-dec [buf] | |
(io/decode utf-codec buf)) | |
(def channel | |
(let [ch (chan)] | |
(go-loop [] | |
(let [ch-data (<! ch) msg (m-dec ch-data)] | |
(println "->" msg) | |
(recur))) | |
ch)) | |
(def server (atom nil)) | |
(defn start-server [] | |
(let [srv (tcp/start-server | |
(fn [s info] | |
(s/connect s channel)) | |
{:port 8888})] | |
(reset! server srv))) | |
Exception in thread "async-dispatch-5" java.lang.Error: java.nio.charset.MalformedInputException: Input length = 1 | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1148) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) | |
at java.lang.Thread.run(Thread.java:745) | |
Caused by: java.nio.charset.MalformedInputException: Input length = 1 | |
at java.nio.charset.CoderResult.throwException(CoderResult.java:281) | |
at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:816) | |
at gloss.data.string.codecs$string_codec$reify__21730.read_bytes(codecs.clj:60) | |
at gloss.core.protocols$compose_callback$reify__20951.read_bytes(protocols.clj:71) | |
at gloss.core.structure$compile_frame$reify__21821.read_bytes(structure.clj:120) | |
at gloss.io$decode.invoke(io.clj:84) | |
at gloss.io$decode.invoke(io.clj:79) | |
at gpsservices.autolink2$m_dec.invoke(autolink2.clj:13) | |
at gpsservices.autolink2$fn__22071$fn__22083$state_machine__13837__auto____22084$fn__22086.invoke(autolink2.clj:17) | |
at gpsservices.autolink2$fn__22071$fn__22083$state_machine__13837__auto____22084.invoke(autolink2.clj:17) | |
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:1011) | |
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:1015) | |
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__13853.invoke(ioc_macros.clj:1024) | |
at clojure.core.async.impl.channels.ManyToManyChannel$fn__8786.invoke(channels.clj:135) | |
at clojure.lang.AFn.run(AFn.java:22) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) | |
... 2 more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment