[Gridflow-cvs] [svn] commit: r3501 - /trunk/base/flow_objects.rb

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Apr 14 20:44:26 EDT 2008


Author: matju
Date: Mon Apr 14 20:44:26 2008
New Revision: 3501

Log:
remove [pd_netsocket]

Modified:
    trunk/base/flow_objects.rb

Modified: trunk/base/flow_objects.rb
==============================================================================
--- trunk/base/flow_objects.rb (original)
+++ trunk/base/flow_objects.rb Mon Apr 14 20:44:26 2008
@@ -91,92 +91,6 @@
   def _1_list(*format) @format = format.join(" ") end
   alias _1_symbol _1_list
 }
-
-class PDNetSocket < FObject
-	def initialize(host,port,protocol=:udp,*options)
-		super
-		_1_connect(host,port,protocol)
-		@options = {}
-		options.each {|k|
-			k=k.intern if String===k
-			@options[k]=true
-		}
-	end
-	def _1_connect(host,port,protocol=:udp)
-		host = host.to_s
-		port = port.to_i
-		@host, at port, at protocol = host.to_s,port.to_i,protocol
-		case protocol
-		when :udp
-			@socket = UDPSocket.new
-			if host=="-" then @socket.bind nil, port end
-		when :tcp
- 			if host=="-" then @server = TCPServer.new("localhost",port)
-			else              @socket = TCPSocket.new(host,port) end
-		end
-		@clock = Clock.new self
-		@clock.delay 0
-		@data = ""
-	end
-	def encode(x)
-		x=x.to_i if @options[:nofloat] and Float===x
-		x.to_s
-	end
-	def method_missing(sel,*args)
-		sel=sel.to_s
-		sel.sub!(/^_\d_/, "") or return super
-		sel=(case sel; when "int","float"; ""; else encode(sel) end)
-		msg = [sel,*args.map{|arg| encode(arg) }].join(" ")
-		if @options[:nosemicolon] then msg << "\n" else msg << ";\n" end
-		post "encoding as: %s", msg.inspect if @options[:debug]
-		case @protocol
-		when :udp; @socket.send msg, 0, @host, @port
-		when :tcp; @socket.send msg, 0
-		end
-	end
-	def delete; @clock.unset; @socket.close end
-	def decode s
-		post "decoding from: %s", s.inspect if @options[:debug]
-		s.chomp!("\n")
-		s.chomp!("\r")
-		s.chomp!(";")
-		a=s.split(/[\s\0]+/)
-		a.shift if a[0]==""
-		a.map {|x|
-			case x
-			when /-?\d+$/; x.to_i
-			when /-?\d/; x.to_f
-			else x.intern
-			end
-		}
-	end
-	def call
-		ready_to_accept = IO.select [@server],[],[],0 if @server
-		if ready_to_accept
-			@socket.close if @socket
-			@socket = @server.accept
-		end
-		ready_to_read = IO.select [@socket],[],[],0 if @socket
-		return if not ready_to_read
-		case @protocol
-		when :udp
-			data,sender = @socket.recvfrom 1024
-			send_out 1, sender.map {|x| x=x.intern if String===x; x }
-			send_out 0, *(decode data)
-		when :tcp
-			@data << @socket.sysread(1024)
-			sender = @socket.peeraddr
-			loop do
-				n = /\n/ =~ @data
-				break if not n
-				send_out 1, sender.map {|x| x=x.intern if String===x; x }
-				send_out 0, *(decode @data.slice!(0..n))
-			end
-		end
-		@clock.delay 50
-	end
-	install "pd_netsocket", 2, 2
-end
 
 FObject.subclass("printargs",1,0) {
   def initialize(*args)



More information about the Gridflow-cvs mailing list