Skip to content
Browse files

Add `remotePort` and `address` properties for the connection object.

  • Loading branch information...
1 parent da1e187 commit 643d301e009f382fe20e62d785c5a1bfde9350bf @majek majek committed Oct 26, 2011
Showing with 11 additions and 0 deletions.
  1. +6 −0 README.md
  2. +5 −0 src/transport.coffee
View
6 README.md
@@ -189,6 +189,12 @@ has following methods and properties:
<dt>Property: remoteAddress (string)</dt>
<dd>Last known IP address of the client.</dd>
+<dt>Property: remotePort (number)</dt>
+<dd>Last known port number of the client.</dd>
+
+<dt>Property: address (object)</dt>
+<dd>Hash with 'address' and 'port' fields.</dd>
+
<dt>write(message)</dt>
<dd>Sends a message over opened connection. A message must be a
non-empty string that can be encoded using UTF-8. The message must
View
5 src/transport.coffee
@@ -82,6 +82,11 @@ class Session
unless socket = @recv.connection
socket = @recv.response.connection
@connection.remoteAddress = socket.remoteAddress
+ @connection.remotePort = socket.remotePort
+ try
+ @connection.address = socket.address()
+ catch e
+ @connection.address = {}
# first, send the open frame
if @readyState is Transport.CONNECTING

0 comments on commit 643d301

Please sign in to comment.
Something went wrong with that request. Please try again.