Permalink
Browse files

Shuffle specs around to make R13 happy

  • Loading branch information...
1 parent 06a0537 commit 7e609cea7d1fa1b8ef6bd76a4c76f1aaad275f74 @majek majek committed Mar 6, 2012
Showing with 40 additions and 35 deletions.
  1. +5 −4 src/mochijson2_fork.erl
  2. +23 −20 src/sockjs_internal.hrl
  3. +12 −11 src/sockjs_session.erl
View
@@ -91,6 +91,9 @@
-define(IS_WHITESPACE(C),
(C =:= $\s orelse C =:= $\t orelse C =:= $\r orelse C =:= $\n)).
+-type(decoder_option() :: any()).
+-type(handler_option() :: any()).
+
-type(json_string() :: atom | binary()).
-type(json_number() :: integer() | float()).
-type(json_array() :: [json_term()]).
@@ -109,10 +112,10 @@
column=1,
state=null}).
+-type(utf8_option() :: boolean()).
+-type(encoder_option() :: handler_option() | utf8_option()).
-spec encoder([encoder_option()]) -> function().
%% @doc Create an encoder/1 with the given options.
--type(encoder_option() :: handler_option() | utf8_option()).
--type(utf8_option() :: boolean()).
%% Emit unicode as utf8 (default - false)
encoder(Options) ->
State = parse_encoder_options(Options, #encoder{}),
@@ -123,8 +126,6 @@ encoder(Options) ->
encode(Any) ->
json_encode(Any, #encoder{}).
--type(decoder_option() :: any()).
--type(handler_option() :: any()).
-spec decoder([decoder_option()]) -> function().
%% @doc Create a decoder/1 with the given options.
decoder(Options) ->
View
@@ -1,29 +1,32 @@
--record(service, {prefix :: nonempty_string(),
- callback :: callback(),
- state :: any(),
- sockjs_url :: nonempty_string(),
- cookie_needed :: boolean(),
- websocket :: boolean(),
+-type(req() :: {cowboy, any()}).
+
+-type(user_session() :: nonempty_string()).
+-type(emittable() :: init|closed|{recv, binary()}).
+-type(callback() :: fun((user_session(), emittable(), any()) -> ok)).
+-type(logger() :: fun((any(), req(), websocket|http) -> req())).
+
+-record(service, {prefix :: nonempty_string(),
+ callback :: callback(),
+ state :: any(),
+ sockjs_url :: nonempty_string(),
+ cookie_needed :: boolean(),
+ websocket :: boolean(),
disconnect_delay :: non_neg_integer(),
- heartbeat_delay :: non_neg_integer(),
- response_limit :: non_neg_integer(),
- logger :: fun((service(), req(), websocket|http) -> req())
- }).
+ heartbeat_delay :: non_neg_integer(),
+ response_limit :: non_neg_integer(),
+ logger :: logger()
+ }).
-type(service() :: #service{}).
--type(req() :: {cowboy, any()}).
-type(headers() :: list({nonempty_string(), nonempty_string()})).
--type(server() :: nonempty_string()).
+-type(server() :: nonempty_string()).
-type(session() :: nonempty_string()).
--type(user_session() :: nonempty_string()).
--type(emittable() :: init|closed|{recv, binary()}).
--type(callback() :: fun((user_session(), emittable(), any()) -> ok)).
--type(frame() :: {open, nil} |
- {close, {non_neg_integer(), string()}} |
- {data, list(iodata())} |
- {heartbeat, nil} ).
+-type(frame() :: {open, nil} |
+ {close, {non_neg_integer(), string()}} |
+ {data, list(iodata())} |
+ {heartbeat, nil} ).
--type(info() :: [{atom(), any()}]).
+-type(info() :: [{atom(), any()}]).
View
@@ -10,23 +10,24 @@
-export([init/1, handle_call/3, handle_info/2, terminate/2, code_change/3,
handle_cast/2]).
--record(session, {id :: session() | undefined,
+-include("sockjs_internal.hrl").
+-type(handle() :: {?MODULE, {pid(), info()}}).
+
+-record(session, {id :: session(),
outbound_queue = queue:new() :: queue(),
- response_pid :: pid() | undefined,
- disconnect_tref :: reference() | undefined,
- disconnect_delay :: non_neg_integer(),
- heartbeat_tref :: reference() | undefined | triggered,
- heartbeat_delay :: non_neg_integer(),
+ response_pid :: pid(),
+ disconnect_tref :: reference(),
+ disconnect_delay = 5000 :: non_neg_integer(),
+ heartbeat_tref :: reference() | triggered,
+ heartbeat_delay = 25000 :: non_neg_integer(),
ready_state = connecting :: connecting | open | closed,
- close_msg :: {non_neg_integer(), string()} | undefined,
+ close_msg :: {non_neg_integer(), string()},
callback,
state,
- handle :: handle()}).
+ handle :: handle()
+ }).
-define(ETS, sockjs_table).
--type(handle() :: {?MODULE, {pid(), info()}}).
-
--include("sockjs_internal.hrl").
-type(session_or_undefined() :: session() | undefined).
-type(session_or_pid() :: session() | pid()).

0 comments on commit 7e609ce

Please sign in to comment.