Class: Vines::Stream::Client
- Inherits:
-
Vines::Stream
- Object
- EventMachine::Connection
- Vines::Stream
- Vines::Stream::Client
- Defined in:
- lib/vines/stream/client.rb,
lib/vines/stream/client/tls.rb,
lib/vines/stream/client/auth.rb,
lib/vines/stream/client/bind.rb,
lib/vines/stream/client/ready.rb,
lib/vines/stream/client/start.rb,
lib/vines/stream/client/closed.rb,
lib/vines/stream/client/session.rb,
lib/vines/stream/client/auth_restart.rb,
lib/vines/stream/client/bind_restart.rb
Overview
Implements the XMPP protocol for client-to-server (c2s) streams. This serves connected streams using the jabber:client namespace.
Direct Known Subclasses
Defined Under Namespace
Classes: Auth, AuthRestart, Bind, BindRestart, Closed, Ready, Session, Start, TLS
Constant Summary collapse
- MECHANISMS =
%w[PLAIN].freeze
Constants inherited from Vines::Stream
Instance Attribute Summary
Attributes inherited from Vines::Stream
Instance Method Summary collapse
-
#authentication_mechanisms ⇒ Object
Return an array of allowed authentication mechanisms advertised as client stream features.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(name, *args) ⇒ Object
Delegate behavior to the session that’s storing our stream state.
- #ssl_handshake_completed ⇒ Object
- #start(node) ⇒ Object
- #unbind ⇒ Object
Methods inherited from Vines::Stream
#advance, #available_resources, #cert_domain_matches?, #close_connection, #connected_resources, #create_parser, #encrypt, #encrypt?, #error, #interested_resources, #post_init, #receive_data, #reset, #router, #ssl_verify_peer, #storage, #update_user_streams, #vhost, #write
Methods included from Log
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Delegate behavior to the session that’s storing our stream state.
16 17 18 |
# File 'lib/vines/stream/client.rb', line 16 def method_missing(name, *args) @session.send(name, *args) end |
Instance Method Details
#authentication_mechanisms ⇒ Object
Return an array of allowed authentication mechanisms advertised as client stream features.
34 35 36 |
# File 'lib/vines/stream/client.rb', line 34 def authentication_mechanisms MECHANISMS end |
#ssl_handshake_completed ⇒ Object
38 39 40 41 42 |
# File 'lib/vines/stream/client.rb', line 38 def ssl_handshake_completed if get_peer_cert close_connection unless cert_domain_matches?(@session.domain) end end |
#start(node) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vines/stream/client.rb', line 49 def start(node) to, from = %w[to from].map {|a| node[a] } @session.domain = to unless @session.domain send_stream_header(from) raise StreamErrors::NotAuthorized if domain_change?(to) raise StreamErrors::UnsupportedVersion unless node['version'] == '1.0' raise StreamErrors::ImproperAddressing unless valid_address?(@session.domain) raise StreamErrors::HostUnknown unless config.vhost?(@session.domain) raise StreamErrors::InvalidNamespace unless node.namespaces['xmlns'] == NAMESPACES[:client] raise StreamErrors::InvalidNamespace unless node.namespaces['xmlns:stream'] == NAMESPACES[:stream] end |
#unbind ⇒ Object
44 45 46 47 |
# File 'lib/vines/stream/client.rb', line 44 def unbind @session.unbind!(self) super end |