terry-xiaoyu 6 лет назад
Родитель
Сommit
18edf5cec3
2 измененных файлов с 4 добавлено и 2 удалено
  1. 2 1
      src/emqx_channel.erl
  2. 2 1
      src/emqx_types.erl

+ 2 - 1
src/emqx_channel.erl

@@ -172,7 +172,7 @@ set_field(Name, Val, Channel) ->
 %%--------------------------------------------------------------------
 
 -spec(init(emqx_types:conninfo(), proplists:proplist()) -> channel()).
-init(ConnInfo = #{peername := {PeerHost, _Port}}, Options) ->
+init(ConnInfo = #{peername := {PeerHost, _Port}, protocol := Protocol}, Options) ->
     Zone = proplists:get_value(zone, Options),
     Peercert = maps:get(peercert, ConnInfo, undefined),
     Username = case peer_cert_as_username(Options) of
@@ -183,6 +183,7 @@ init(ConnInfo = #{peername := {PeerHost, _Port}}, Options) ->
                end,
     MountPoint = emqx_zone:get_env(Zone, mountpoint),
     ClientInfo = #{zone         => Zone,
+                   protocol     => Protocol,
                    peerhost     => PeerHost,
                    peercert     => Peercert,
                    client_id    => undefined,

+ 2 - 1
src/emqx_types.erl

@@ -103,6 +103,7 @@
                       atom()   => term()
                      }).
 -type(client() :: #{zone         := zone(),
+                    protocol     := protocol(),
                     peerhost     := peerhost(),
                     client_id    := client_id(),
                     username     := username(),
@@ -121,7 +122,7 @@
 -type(password() :: maybe(binary())).
 -type(peerhost() :: inet:ip_address()).
 -type(peername() :: {inet:ip_address(), inet:port_number()}).
--type(protocol() :: mqtt | 'mqtt-sn' | coap | stomp | none | atom()).
+-type(protocol() :: mqtt | 'mqtt-sn' | coap | lwm2m | stomp | none | atom()).
 -type(auth_result() :: success
                      | client_identifier_not_valid
                      | bad_username_or_password