Author: mkirby
Date: 2012-05-30 15:54:53 -0700 (Wed, 30 May 2012)
New Revision: 29401

Modified:
   csplugins/trunk/soc/mkirby/R/cytobridge.R
Log:
mkirby: Got socket communication between R and Java working.

Modified: csplugins/trunk/soc/mkirby/R/cytobridge.R
===================================================================
--- csplugins/trunk/soc/mkirby/R/cytobridge.R   2012-05-30 21:27:32 UTC (rev 
29400)
+++ csplugins/trunk/soc/mkirby/R/cytobridge.R   2012-05-30 22:54:53 UTC (rev 
29401)
@@ -1,9 +1,9 @@
 #make your igraph
-g1 <- graph( c( 0,1, 1,2, 2,2, 2,3 ) )
+g1 <- graph.ring(100000)
 
 #The Cytobridge class
 setClass(Class="cytobridge", 
-          representation=representation(a="ANY"),
+          representation=representation(a="ANY", s="ANY"),
           prototype=prototype(a=graph(c(0,1))),
           validity=function(object) {
               if(class(object@a)!="igraph") {
@@ -23,8 +23,29 @@
 setGeneric(name="update", def=function(x) standardGeneric("update"))
         setMethod(f="update", signature="cytobridge",
             definition=function(x) {
-                print(V(getGraph(x)))
+                   socket <- make.socket("localhost", "4444")
+                   on.exit(close.socket(socket))
+                   write.socket(socket, 
paste(as.character(x@s),toString(x@a),"endRSend"))
+                   close.socket(socket)
         })
 
+setGeneric(name="connect", def=function(x) standardGeneric("connect"))
+        setMethod(f="connect", signature="cytobridge",
+            definition=function(x) {
+                   x@s <- 1234 #some unique id
+                   return(x)
+        })
 
-test <- new("cytobridge",a=g1)
\ No newline at end of file
+setGeneric(name="close", def=function(x) standardGeneric("close"))
+        setMethod(f="close", signature="cytobridge",
+            definition=function(x) {
+                   socket <- make.socket("localhost", "4444")
+                   on.exit(close.socket(socket))
+                   write.socket(socket, "die")
+                   close.socket(socket)
+                x@s <- 0 #resets id
+        })
+
+test <- new("cytobridge",a=g1)
+test <- connect(test)
+update(test)
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to