Class: OSC::TCP::SendingSocket
- Inherits:
-
Object
- Object
- OSC::TCP::SendingSocket
- Defined in:
- lib/qlab-ruby/core-ext/osc-ruby/sending_socket.rb
Overview
A wrapper around an open TCP socket providing SLIP encoding for outbound messages.
Instance Method Summary collapse
-
#initialize(socket) ⇒ SendingSocket
constructor
A new instance of SendingSocket.
-
#send(msg) ⇒ Object
send SLIP encoded OSC messages.
Constructor Details
#initialize(socket) ⇒ SendingSocket
Returns a new instance of SendingSocket.
6 7 8 |
# File 'lib/qlab-ruby/core-ext/osc-ruby/sending_socket.rb', line 6 def initialize socket @socket = socket end |
Instance Method Details
#send(msg) ⇒ Object
send SLIP encoded OSC messages
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/qlab-ruby/core-ext/osc-ruby/sending_socket.rb', line 11 def send msg @socket_buffer = [] enc_msg = msg.encode send_char CHAR_END enc_msg.bytes.each do |b| case b when CHAR_END send_char CHAR_ESC send_char CHAR_ESC_END when CHAR_ESC send_char CHAR_ESC send_char CHAR_ESC_ESC else send_char b end end send_char CHAR_END flush end |