module ShadowsocksRuby::Protocols::DummyHelper
This module include helper methods for a Packet/Cipher/Obfs Protocol.
To simplify boring long method name writing (eg: tcp_receive_from_client, tcp_send_to_client), two Adapter method are introduced and could be untilized: #async_recv
and #send_data
, they will be adapted to long method names (eg: tcp_receive_from_client, tcp_send_to_client) at runtime.
This helper module implement dummy {#async_recv} and {#send_data}, do nothing but just raise, in order to make things clear.
To use it, use +include DummyHelper+ to include it into your protocol implementation.
Public Instance Methods
Receive n bytes of data @param n length of data to receive @raise ProtocolError
@return [String] Should return real data on runtime
# File lib/shadowsocks_ruby/protocols/protocol.rb, line 62 def async_recv n raise ProtocolError, "async_recv must be set before use" end
If user code don't want to implement a method, it can call this to raise Error. @raise UnimplementError
# File lib/shadowsocks_ruby/protocols/protocol.rb, line 75 def raise_me *args raise UnimplementError, "Some day may implement this: " + caller[0][/`.*'/][1..-2] end
Send data @param data data to send @raise ProtocolError
# File lib/shadowsocks_ruby/protocols/protocol.rb, line 69 def send_data data raise ProtocolError, "send_data must be set before use" end