Removed legacy code
Removed all traces of ObserverInterface Added getRemoteAddress method to socket
This commit is contained in:
parent
84484f6603
commit
62962bb27f
@ -5,7 +5,7 @@ use Ratchet\Resource\Connection;
|
||||
interface ApplicationInterface {
|
||||
/**
|
||||
* Decorator pattern
|
||||
* @param Ratchet\ObserverInterface Application to wrap in protocol
|
||||
* @param Ratchet\ApplicationInterface Application to wrap in protocol
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function __construct(ApplicationInterface $app = null);
|
||||
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
namespace Ratchet;
|
||||
|
||||
/**
|
||||
* Observable/Observer design pattern interface for handing events on a socket
|
||||
* @todo Consider an onDisconnect method for a server-side close()'ing of a connection - onClose would be client side close()
|
||||
* @todo Is this interface needed anymore?
|
||||
* @deprecated
|
||||
*/
|
||||
interface ObserverInterface {
|
||||
/**
|
||||
* When a new connection is opened it will be passed to this method
|
||||
* @param SocketInterface The socket/connection that just connected to your application
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onOpen(SocketInterface $conn);
|
||||
|
||||
/**
|
||||
* Triggered when a client sends data through the socket
|
||||
* @param SocketInterface The socket/connection that sent the message to your application
|
||||
* @param string The message received
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onMessage(SocketInterface $from, $msg);
|
||||
|
||||
/**
|
||||
* This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
|
||||
* @param SocketInterface The socket/connection that is closing/closed
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onClose(SocketInterface $conn);
|
||||
|
||||
/**
|
||||
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
|
||||
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
|
||||
* @param SocketInterface
|
||||
* @param \Exception
|
||||
* @return Ratchet\Resource\Command\CommandInterface|null
|
||||
*/
|
||||
function onError(SocketInterface $conn, \Exception $e);
|
||||
}
|
@ -9,7 +9,7 @@ use Ratchet\Application\ApplicationInterface;
|
||||
interface CommandInterface {
|
||||
/**
|
||||
* The Server class will call the execution
|
||||
* @param Ratchet\ObserverInterface Scope to execute the command under
|
||||
* @param Ratchet\ApplicationInterface Scope to execute the command under
|
||||
* @return CommandInterface|NULL
|
||||
*/
|
||||
function execute(ApplicationInterface $scope = null);
|
||||
|
@ -91,6 +91,15 @@ class Socket implements SocketInterface {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRemoteAddress() {
|
||||
$address = $port = '';
|
||||
if (false === @socket_getpeername($this->getResource(), $address, $port)) {
|
||||
throw new Exception;
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
public function get_option($level, $optname) {
|
||||
if (false === ($res = @socket_get_option($this->getResource(), $level, $optname))) {
|
||||
throw new Exception;
|
||||
|
@ -54,6 +54,13 @@ interface SocketInterface {
|
||||
*/
|
||||
function connect($address, $port = 0);
|
||||
|
||||
/**
|
||||
* Get the address the socket connected from
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
function getRemoteAddress();
|
||||
|
||||
/**
|
||||
* @param int
|
||||
* @param int
|
||||
|
Loading…
Reference in New Issue
Block a user