001/* 002 * Copyright 2006 - 2013 003 * Stefan Balev <stefan.balev@graphstream-project.org> 004 * Julien Baudry <julien.baudry@graphstream-project.org> 005 * Antoine Dutot <antoine.dutot@graphstream-project.org> 006 * Yoann Pigné <yoann.pigne@graphstream-project.org> 007 * Guilhelm Savin <guilhelm.savin@graphstream-project.org> 008 * 009 * This file is part of GraphStream <http://graphstream-project.org>. 010 * 011 * GraphStream is a library whose purpose is to handle static or dynamic 012 * graph, create them from scratch, file or any source and display them. 013 * 014 * This program is free software distributed under the terms of two licenses, the 015 * CeCILL-C license that fits European law, and the GNU Lesser General Public 016 * License. You can use, modify and/ or redistribute the software under the terms 017 * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following 018 * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by 019 * the Free Software Foundation, either version 3 of the License, or (at your 020 * option) any later version. 021 * 022 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 023 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 024 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 025 * 026 * You should have received a copy of the GNU Lesser General Public License 027 * along with this program. If not, see <http://www.gnu.org/licenses/>. 028 * 029 * The fact that you are presently reading this means that you have had 030 * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms. 031 */ 032package org.graphstream.stream.netstream; 033 034/** 035 * <h1 class="title">NetStream</h1> 036 * 037 * <p> 038 * The NetStream framework allows to export the idea of "streams of graph 039 * events" to other languages than Java, through a network interface. The 040 * aim is mainly to allow the use of GraphStream with other projects written in 041 * other languages. However, since it is a network interface it also allows the 042 * use of several machines. The protocol is optimized to be have as low overhead 043 * as possible. 044 * </p> 045 * <p> 046 * If you are looking for a Java-to-Java network link between GraphStream and 047 * some other project, you may prefer GraphStream's <a 048 * class="reference external" href= 049 * "http://graphstream-project.org/doc/Tutorials/Using-remote-source_1.0/" 050 * >RMI</a> facilities. 051 * </p> 052 * <p> 053 * This document is organized in 3 sections. The first one details the 054 * Receiver's mechanisms. The second section describes the Sender. The last 055 * section details the NetStream Protocol. 056 * </p> 057 * <div class="section" id="receiver"> <h1>Receiver</h1> 058 * <p> 059 * This one is responsible for receiving graph events from the network following 060 * the "NetStream" protocol. Events are then dispatched to pipes 061 * according to a given names. Here we consider that several stream of events 062 * (independent one another) can be handled by the receiver. We thus introduce 063 * the idea of <strong>stream ID</strong> where a stream is identified by an ID. 064 * </p> 065 * <p> 066 * The Receiver is composed of: 067 * </p> 068 * <ul class="simple"> 069 * <li>A socket server that handles multiples connections directed to multiple 070 * streams (pipes). That part is mostly a copy/past from Antoine's "MBox 071 * Receiver" code.</li> 072 * <li>An implementation of the NetStream Protocol (see below) that parses the 073 * received byte arrays and creates/sends graph events to specified pipes.</li> 074 * <li>a set of streams (ThreadProxyPipes) identified by an ID. From 075 * GraphStream's point of view, the NetStreamReceriver provides sources 076 * (actually pipes) on which sinks (or other pipes) can connect to, to receive 077 * graph events.</li> 078 * </ul> 079 * <p> 080 * The Receiver's general behavior is: 081 * </p> 082 * <ul class="simple"> 083 * <li>Wait for messages from any sender received data is stored separately for 084 * each sender until a message is completely received. The receiver knows about 085 * a complete message because the first 4 bytes of the messages are an integer 086 * that gives the size of the message.</li> 087 * <li>A complete message is decoded (according to the NetStream Protocol), an 088 * event is created and sent to the specified stream (pipe)</li> 089 * </ul> 090 * <p> 091 * The graph event receiver listens at a given address and port. It runs on its 092 * own thread. Several senders can connect to it, the receiver will demultiplex 093 * the data flow and dispatch incoming events to specified pipes. No extra 094 * thread are created when client connect. 095 * </p> 096 * <p> 097 * From the graph event stream point of view, the NetStream receiver can be seen 098 * as a set of pipes identified by an id. When an event is received is is 099 * directed to one specific stream. By default, senders not willing to handle 100 * different streams may send to the stream called "default". 101 * </p> 102 * <p> 103 * The only way to receive events from the network is to ask for a stream by 104 * means of a ThreadProxyPipe to the Receiver. The 105 * <tt class="docutils literal">getStream()</tt> and 106 * <tt class="docutils literal">getDefaultStream()</tt> give access to such 107 * pipe. Asking a non-existing stream (with an unknown id) will create it, so 108 * those functions always return a pipe. On the opposite, any new stream 109 * introduced by a sender will be created by the receiver. 110 * </p> 111 * 112 * <div class="section" id="example"> <h2> 113 * Example</h2> 114 * 115 * <pre class="code-java literal-block"> 116 * import java.io.IOException; 117 * import java.net.UnknownHostException; 118 * 119 * import org.graphstream.graph.Graph; 120 * import org.graphstream.graph.implementations.MultiGraph; 121 * import org.graphstream.stream.thread.ThreadProxyPipe; 122 * 123 * // A simple example of use of the NetStream receiver. 124 * 125 * public class ReceiverExample { 126 * 127 * public static void main(String[] args) throws UnknownHostException, 128 * IOException, InterruptedException { 129 * // ----- On the receiver side ----- 130 * // 131 * // - a graph that will display the received events 132 * Graph g = new MultiGraph("G"); 133 * g.display(); 134 * // - the receiver that waits for events 135 * NetStreamReceiver net = new NetStreamReceiver(2001); 136 * // - received events end up in the "default" pipe 137 * ThreadProxyPipe pipe = net.getDefaultStream(); 138 * // - plug the pipe to the sink of the graph 139 * pipe.addSink(g); 140 * // -The receiver pro-actively checks for events on the ThreadProxyPipe 141 * while (true) { 142 * pipe.pump(); 143 * Thread.sleep(100); 144 * } 145 * } 146 * } 147 * </pre> 148 * 149 * </div> </div> <div class="section" id="sender"> <h1>Sender</h1> 150 * <p> 151 * A sender, from the GraphStream API, is first of all a sink where one can plug 152 * sources so that it can receive events. Receiving these events the sender will 153 * pack them into messages according to the NetStream Protocol and then send 154 * those messages to a defined receiver through a given <strong>port</strong>, 155 * <strong>host</strong> and <strong>stream ID</strong>. 156 * </p> 157 * <div class="section" id="id1"> <h2>Example</h2> 158 * 159 * <pre class="code-java literal-block"> 160 * import java.io.IOException; 161 * import java.net.UnknownHostException; 162 * 163 * import org.graphstream.graph.Graph; 164 * import org.graphstream.graph.implementations.MultiGraph; 165 * 166 * // A simple example of use of the NetStream sender. 167 * 168 * public class SenderExample { 169 * 170 * public static void main(String[] args) { 171 * Graph g = new MultiGraph("G"); 172 * // - the sender 173 * NetStreamSender nsc = null; 174 * try { 175 * nsc = new NetStreamSender(2001); 176 * } catch (UnknownHostException e) { 177 * e.printStackTrace(); 178 * } catch (IOException e) { 179 * e.printStackTrace(); 180 * } 181 * // - plug the graph to the sender so that graph events can be 182 * // sent automatically 183 * g.addSink(nsc); 184 * // - generate some events on the client side 185 * String style = "node{fill-mode:plain;fill-color:#567;size:6px;}"; 186 * g.addAttribute("stylesheet", style); 187 * g.addAttribute("ui.antialias", true); 188 * g.addAttribute("layout.stabilization-limit", 0); 189 * for (int i = 0; i < 500; i++) { 190 * g.addNode(i + ""); 191 * if (i > 0) { 192 * g.addEdge(i + "-" + (i - 1), i + "", (i - 1) + ""); 193 * g.addEdge(i + "--" + (i / 2), i + "", (i / 2) + ""); 194 * } 195 * } 196 * } 197 * 198 * } 199 * </pre> 200 * 201 * </div> </div> <div class="section" id="the-netstream-protocol"> <h1>The 202 * NetStream Protocol</h1> 203 * <p> 204 * Messages in the NetStream protocol are specified a the byte level. It is 205 * different than an XML-based protocols like client/server REST approaches. 206 * Here the content and different formats constituting a message are optimize as 207 * much as possible, so as to reduce the network payload. 208 * </p> 209 * <p> 210 * A message, as it is created by a sender, is composed of three main parts: 211 * <ol class="arabic simple"> 212 * <li>A 4 bytes integer that indicates the size (in bytes) of the remaining of 213 * this message (not including those 4 bytes).</li> 214 * <li>A string, encoded using the NetStream protocol (see 215 * <tt class="docutils literal">TYPE_STRING</tt> below), that identifies the 216 * stream targeted by this event.</li> 217 * <li>The event itself, that can be decoded, according to the NetStream 218 * protocol.</li> 219 * </ol> 220 * <div class="section" id="data-types"> 221 * <h2>Data Types</h2> 222 * <p> 223 * Before sending a value whose type is unknown (integer, double, string, 224 * array...) one have to specify its type (and if applicable, its length) to the 225 * server. Value types are defined to allow the server to recognize the type of 226 * a value. When applicable (strings, tables, raw data) types are followed by a 227 * length. This length is always coded with a 16-bits signed short and usually 228 * represents the number of elements (for arrays). 229 * </p> 230 * <ul> 231 * <li> 232 * <p class="first"> 233 * <tt class="docutils literal">TYPE_BOOLEAN</tt> [0x50] 234 * </p> 235 * <p> 236 * Announces a boolean value. Followed by a byte whose value is 0 (false) or 1 237 * (true). 238 * </p> 239 * </li> 240 * <li> 241 * <p class="first"> 242 * <tt class="docutils literal">TYPE_BOOLEAN_ARRAY</tt> [0X51] 243 * </p> 244 * <p> 245 * Announces an array of boolean values. Followed by first, a 32-bit integer 246 * that indicates the length of this array, and then, by the actual sequence of 247 * booleans. 248 * </p> 249 * </li> 250 * <li> 251 * <p class="first"> 252 * <tt class="docutils literal">TYPE_BYTE</tt> [0x52] 253 * </p> 254 * <p> 255 * Announces a byte. Followed by a 8-bit signed byte. 256 * </p> 257 * </li> 258 * <li> 259 * <p class="first"> 260 * <tt class="docutils literal">TYPE_INT_BYTE</tt> [0x53] 261 * </p> 262 * <p> 263 * Announces an array of bytes. Followed by first, a 32-bit integer that 264 * indicates the length in number of elements of this array, and then, by the 265 * actual sequence of 8-bit signed bytes. 266 * </p> 267 * </li> 268 * <li> 269 * <p class="first"> 270 * <tt class="docutils literal">TYPE_SHORT</tt> [0x54] 271 * </p> 272 * <p> 273 * Announces a short. Followed by a 16-bit signed short. 274 * </p> 275 * </li> 276 * <li> 277 * <p class="first"> 278 * <tt class="docutils literal">TYPE_SHORT_ARRAY</tt> [0x55] 279 * </p> 280 * <p> 281 * Announces an array of shorts. Followed by first, a 32-bit integer that 282 * indicates the length in number of elements of this array, and then, by the 283 * actual sequence of 16-bit signed shorts. 284 * </p> 285 * </li> 286 * <li> 287 * <p class="first"> 288 * <tt class="docutils literal">TYPE_INT</tt> [0x56] 289 * </p> 290 * <p> 291 * Announces an integer. Followed by a 32-bit signed integer. 292 * </p> 293 * </li> 294 * <li> 295 * <p class="first"> 296 * <tt class="docutils literal">TYPE_INT_ARRAY</tt> [0x57] 297 * </p> 298 * <p> 299 * Announces an array of integers. Followed by first, a 32-bit integer that 300 * indicates the length in number of elements of this array, and then, the 301 * actual sequence of 32-bit signed integers. 302 * </p> 303 * </li> 304 * <li> 305 * <p class="first"> 306 * <tt class="docutils literal">TYPE_LONG</tt> [0x58] 307 * </p> 308 * <p> 309 * Announces a long. Followed by a 64-bit signed long. 310 * </p> 311 * </li> 312 * <li> 313 * <p class="first"> 314 * <tt class="docutils literal">TYPE_LONG_ARRAY</tt> [0x59] 315 * </p> 316 * <p> 317 * Announces an array of longs. Followed by first, a 32-bit integer that 318 * indicates the length in number of elements of this array, and then, by the 319 * actual sequence of 64-bit signed longs. 320 * </p> 321 * </li> 322 * <li> 323 * <p class="first"> 324 * <tt class="docutils literal">TYPE_FLOAT</tt> [0x5A] 325 * </p> 326 * <p> 327 * Announces a float. Followed by a 32-bit single precision signed floating 328 * point number. 329 * </p> 330 * </li> 331 * <li> 332 * <p class="first"> 333 * <tt class="docutils literal">TYPE_FLOAT_ARRAY</tt> [0x5B] 334 * </p> 335 * <p> 336 * Announces an array of floats. Followed by first, a 32-bit integer that 337 * indicates the length in number of elements of this array, and then, by the 338 * actual sequence of 32-bit double precision signed floating point numbers. 339 * </p> 340 * </li> 341 * <li> 342 * <p class="first"> 343 * <tt class="docutils literal">TYPE_DOUBLE</tt> [0x5C] 344 * </p> 345 * <p> 346 * Announces a double. Followed by a 64-bit double precision signed floating 347 * point number. 348 * </p> 349 * </li> 350 * <li> 351 * <p class="first"> 352 * <tt class="docutils literal">TYPE_DOUBLE_ARRAY</tt> [0x5D] 353 * </p> 354 * <p> 355 * Announces an array of doubles. Followed by first, a 32-bit integer that 356 * indicates the length in number of elements of this array, and then, by the 357 * actual sequence of 64-bit double precision signed floating point numbers. 358 * </p> 359 * </li> 360 * <li> 361 * <p class="first"> 362 * <tt class="docutils literal">TYPE_STRING</tt> [0x5E] 363 * </p> 364 * <p> 365 * Announces an array of characters. Followed by first, a 32-bits integer for 366 * the size in bytes (not in number of characters) of the string, then by the 367 * unicode string itself. 368 * </p> 369 * </li> 370 * <li> 371 * <p class="first"> 372 * <tt class="docutils literal">TYPE_RAW</tt> [0x5F] 373 * </p> 374 * <p> 375 * Announces raw data, good for serialization or to exchange data the will then 376 * be understood in any language (an image, for instance). Followed by first, a 377 * 16-bits integer indicating the length in bytes of the dataset, and then by 378 * the data itself, as unsigned bytes. 379 * </p> 380 * </li> 381 * <li> 382 * <p class="first"> 383 * <tt class="docutils literal">TYPE_ARRAY</tt> [0x60] 384 * </p> 385 * <p> 386 * Announces an undefined-type array. Followed by first, a 32-bits integer 387 * indicating the number of elements, and then, the elements themselves. The 388 * elements themselves have to give their types. It may contain data of 389 * different types or even other arrays. 390 * </p> 391 * </li> 392 * </ul> 393 * </div> <div class="section" id="graph-events"> <h2>Graph Events</h2> 394 * <p> 395 * the graph event, as created by a sender, is the third part of the whole sent 396 * message. It is made of several parts that differ according the event. The 397 * common information is the first byte of the event, that identifies the event. 398 * Then, other data depending on the event follow up. Those event identifiers 399 * are one byte long. To avoid problems between languages (mainly because of 400 * java) those bytes are unsigned and only positive values are used. So, any 401 * event identifier will take a value between 0 and 127. 402 * </p> 403 * <p> 404 * Here is a list of graph event identifiers followed by the expected 405 * information to fulfill these events: 406 * </p> 407 * <ul> 408 * <li> 409 * <p class="first"> 410 * <tt class="docutils literal">EVENT_ADD_NODE</tt> [0x10] 411 * </p> 412 * <p> 413 * Add a node. Followed by a node id ( 414 * <tt class="docutils literal">TYPE_STRING</tt> format). 415 * </p> 416 * </li> 417 * <li> 418 * <p class="first"> 419 * <tt class="docutils literal">EVENT_DEL_NODE</tt> [0x11] 420 * </p> 421 * <p> 422 * Remove a node. Followed by a node id ( 423 * <tt class="docutils literal">TYPE_STRING</tt> format) 424 * </p> 425 * </li> 426 * <li> 427 * <p class="first"> 428 * <tt class="docutils literal">EVENT_ADD_EDGE</tt> [0x12] 429 * </p> 430 * <p> 431 * Add an edge. Followed by: 432 * </p> 433 * <ul class="simple"> 434 * <li>the edge id (TYPE_STRING format),</li> 435 * <li>the source node id (TYPE_STRING format),</li> 436 * <li>the target node id (TYPE_STRING format</li> 437 * <li>a boolean indicating if the edge is directed (is it an arc?) 438 * (TYPE_BOOLEAN format)</li> 439 * </ul> 440 * </li> 441 * <li> 442 * <p class="first"> 443 * <tt class="docutils literal">EVENT_DEL_NODE</tt> [0x13] 444 * </p> 445 * <p> 446 * Remove an edge. Followed by the string id of this edge. 447 * </p> 448 * </li> 449 * <li> 450 * <p class="first"> 451 * <tt class="docutils literal">EVENT_STEP</tt> [0x14] 452 * </p> 453 * <p> 454 * Time step. Followed by a 64-bit double indicating the timestamp. 455 * </p> 456 * </li> 457 * <li> 458 * <p class="first"> 459 * <tt class="docutils literal">EVENT_CLEARED</tt> [0x15] 460 * </p> 461 * <p> 462 * Clear the graph. This event will remove any attribute or element in the 463 * graph. 464 * </p> 465 * </li> 466 * <li> 467 * <p class="first"> 468 * <tt class="docutils literal">EVENT_ADD_GRAPH_ATTR</tt> [0x16] 469 * </p> 470 * <p> 471 * Add an attribute to the graph. Followed by: 472 * </p> 473 * <ul class="simple"> 474 * <li>the attribute name (TYPE_STRING format)</li> 475 * <li>the attribute value type (one of the bytes shown in the "Data 476 * Types" section)</li> 477 * <li>the attribute value, encoded according to its value type (see the 478 * "Data Types" section)</li> 479 * </ul> 480 * </li> 481 * <li> 482 * <p class="first"> 483 * <tt class="docutils literal">EVENT_CHG_GRAPH_ATTR</tt> [0x17] 484 * </p> 485 * <p> 486 * Change an existing attribute on the graph. Followed by: 487 * </p> 488 * <ul class="simple"> 489 * <li>the attribute name (TYPE_STRING format)</li> 490 * <li>the attribute'd old value type (one of the bytes shown in the "Data 491 * Types" section)</li> 492 * <li>the old attribute value, encoded according to its value type (see the 493 * "Data Types" section)</li> 494 * <li>the attribute's new value type (one of the bytes shown in the "Data 495 * Types" section)</li> 496 * <li>the new attribute value, encoded according to its value type (see the 497 * "Data Types" section)</li> 498 * </ul> 499 * </li> 500 * <li> 501 * <p class="first"> 502 * <tt class="docutils literal">EVENT_DEL_GRAPH_ATTR</tt> [0x18] 503 * </p> 504 * <p> 505 * Remove an attribute from the graph. Followed by the attribute name (encoded 506 * with the TYPE_STRING format). 507 * </p> 508 * </li> 509 * <li> 510 * <p class="first"> 511 * <tt class="docutils literal">EVENT_ADD_NODE_ATTR</tt> [0x19] 512 * </p> 513 * <p> 514 * Add an attribute to a node. Followed by: 515 * </p> 516 * <ul class="simple"> 517 * <li>the ID of the considered node (TYPE_STRING format)</li> 518 * <li>the attribute name (TYPE_STRING format)</li> 519 * <li>the attribute value type (one of the bytes shown in the "Data 520 * Types" section)</li> 521 * <li>the attribute value, encoded according to its value type (see the 522 * "Data Types" section)</li> 523 * </ul> 524 * </li> 525 * <li> 526 * <p class="first"> 527 * <tt class="docutils literal">EVENT_CHG_NODE_ATTR</tt> [0x1A] 528 * </p> 529 * <p> 530 * Change an existing attribute on a given node. Followed by: 531 * </p> 532 * <ul class="simple"> 533 * <li>the ID of the considered node (TYPE_STRING format)</li> 534 * <li>the attribute name (TYPE_STRING format)</li> 535 * <li>the attribute's old value type (one of the bytes shown in the "Data 536 * Types" section)</li> 537 * <li>the old attribute value, encoded according to its value type (see the 538 * "Data Types" section)</li> 539 * <li>the attribute's new value type (one of the bytes shown in the "Data 540 * Types" section)</li> 541 * <li>the new attribute value, encoded according to its value type (see the 542 * "Data Types" section)</li> 543 * </ul> 544 * </li> 545 * <li> 546 * <p class="first"> 547 * <tt class="docutils literal">EVENT_DEL_NODE_ATTR</tt> [0x1B] 548 * </p> 549 * <p> 550 * Remove an attribute from a given node. Followed by: 551 * </p> 552 * <ul class="simple"> 553 * <li>the ID of the considered node (TYPE_STRING format)</li> 554 * <li>the attribute name (encoded with the TYPE_STRING format).</li> 555 * </ul> 556 * </li> 557 * <li> 558 * <p class="first"> 559 * <tt class="docutils literal">EVENT_ADD_EDGE_ATTR</tt> [0x1C] 560 * </p> 561 * <p> 562 * Add an attribute to an edge. Followed by: 563 * </p> 564 * <ul class="simple"> 565 * <li>the ID of the considered edge (TYPE_STRING format)</li> 566 * <li>the attribute name (TYPE_STRING format)</li> 567 * <li>the attribute value type (one of the bytes shown in the "Data 568 * Types" section)</li> 569 * <li>the attribute value, encoded according to its value type (see the 570 * "Data Types" section)</li> 571 * </ul> 572 * </li> 573 * <li> 574 * <p class="first"> 575 * <tt class="docutils literal">EVENT_CHG_EDGE_ATTR</tt> [0x1D] 576 * </p> 577 * <p> 578 * Change an existing attribute on a given edge. Followed by: 579 * </p> 580 * <ul class="simple"> 581 * <li>the ID of the considered edge (TYPE_STRING format)</li> 582 * <li>the attribute name (TYPE_STRING format)</li> 583 * <li>the attribute's old value type (one of the bytes shown in the "Data 584 * Types" section)</li> 585 * <li>the old attribute value, encoded according to its value type (see the 586 * "Data Types" section)</li> 587 * <li>the attribute's new value type (one of the bytes shown in the "Data 588 * Types" section)</li> 589 * <li>the new attribute value, encoded according to its value type (see the 590 * "Data Types" section)</li> 591 * </ul> 592 * </li> 593 * <li> 594 * <p class="first"> 595 * <tt class="docutils literal">EVENT_DEL_EDGE_ATTR</tt> [0x1E] 596 * </p> 597 * <p> 598 * Remove an attribute from a given edge. Followed by: 599 * </p> 600 * <ul class="simple"> 601 * <li>the ID of the considered edge (TYPE_STRING format)</li> 602 * <li>the attribute name (encoded with the TYPE_STRING format).</li> 603 * </ul> 604 * </li> 605 * </ul> 606 * </div> </div> 607 * 608 * 609 * 610 * Copyright (c) 2010-2012 University of Luxembourg - University of Le Havre 611 * 612 * NetStreamConstants.java 613 * @since Aug 3, 2011 614 * 615 * @author Yoann Pigné 616 * 617 */ 618public class NetStreamConstants { 619 /** 620 * Followed by an 32-bit signed integer for this protocol version. Certainly 621 * useless. 622 */ 623 public static int EVENT_GETVERSION = 0x00; 624 /** 625 * Not used. 626 */ 627 public static int EVENT_START = 0x01; 628 629 /** 630 * Constant indicating that the client has disconnected. 631 */ 632 public static int EVENT_END = 0x02; 633 634 // 635 // ---------------------------------- 636 // GraphStream's graph events 637 // ---------------------------------- 638 // 639 640 /** 641 * Followed by a node id (TYPE_STRING format) 642 */ 643 public static int EVENT_ADD_NODE = 0x10; 644 645 /** 646 * Followed by a node id (TYPE_STRING format) 647 */ 648 public static int EVENT_DEL_NODE = 0x11; 649 650 /** 651 * Followed by - an edge id (TYPE_STRING format), - an source node id 652 * (TYPE_STRING format), - a target node id (TYPE_STRING format - a boolean 653 * indicating if directed (TYPE_BOOLEAN format) 654 */ 655 public static int EVENT_ADD_EDGE = 0x12; 656 657 /** 658 * Followed by an edge id (TYPE_STRING format) 659 */ 660 public static int EVENT_DEL_EDGE = 0x13; 661 662 /** 663 * Followed by double (TYPE_DOUBLE format) 664 */ 665 public static int EVENT_STEP = 0x14; 666 /** 667 * 668 */ 669 public static int EVENT_CLEARED = 0x15; 670 671 /** 672 * Followed by - an attribute id (TYPE_STRING format) - the attribute TYPE - 673 * the attribute value 674 */ 675 public static int EVENT_ADD_GRAPH_ATTR = 0x16; 676 /** 677 * Followed by - an attribute id (TYPE_STRING format) - the attribute TYPE - 678 * the attribute old value - the attribute new value 679 */ 680 public static int EVENT_CHG_GRAPH_ATTR = 0x17; 681 /** 682 * Followed by - the attribute id (TYPE_STRING format) 683 */ 684 public static int EVENT_DEL_GRAPH_ATTR = 0x18; 685 686 /** 687 * Followed by - an attribute id (TYPE_STRING format) - the attribute TYPE - 688 * the attribute value 689 */ 690 public static int EVENT_ADD_NODE_ATTR = 0x19; 691 /** 692 * Followed by - an attribute id (TYPE_STRING format) - the attribute TYPE - 693 * the attribute old value - the attribute new value 694 */ 695 public static int EVENT_CHG_NODE_ATTR = 0x1a; 696 /** 697 * Followed by - the node id (TYPE_STRING format) - the attribute id 698 * (TYPE_STRING format) 699 */ 700 public static int EVENT_DEL_NODE_ATTR = 0x1b; 701 702 /** 703 * Followed by - an attribute id (TYPE_STRING format) - the attribute TYPE - 704 * the attribute value 705 */ 706 public static int EVENT_ADD_EDGE_ATTR = 0x1c; 707 /** 708 * Followed by - an attribute id (TYPE_STRING format) - the attribute TYPE - 709 * the attribute old value - the attribute new value 710 */ 711 public static int EVENT_CHG_EDGE_ATTR = 0x1d; 712 /** 713 * Followed by - the edge id (TYPE_STRING format) - the attribute id 714 * (TYPE_STRING format) 715 */ 716 public static int EVENT_DEL_EDGE_ATTR = 0x1e; 717 718 // Values types 719 720 public static int TYPE_UNKNOWN = 0x00; 721 722 /** 723 * Followed by a byte who's value is 0 or 1 724 */ 725 public static int TYPE_BOOLEAN = 0x50; 726 /** 727 * An array of booleans. Followed by first, a 16-bits integer for the number 728 * of booleans and then, a list of bytes who's value is 0 or 1 729 */ 730 public static int TYPE_BOOLEAN_ARRAY = 0x51; 731 /** 732 * Followed by a signed byte [-127,127] 733 */ 734 public static int TYPE_BYTE = 0x52; 735 /** 736 * An array of bytes. Followed by first, a 16-bits integer for the number of 737 * integers and then, a list of signed bytes. 738 */ 739 public static int TYPE_BYTE_ARRAY = 0x53; 740 /** 741 * Followed by an 16-bit signed integer (a short) 742 */ 743 public static int TYPE_SHORT = 0x54; 744 /** 745 * An array of shorts. Followed by first, a 16-bits integer for the number 746 * of integers and then, a list of 16-bit signed shorts 747 */ 748 public static int TYPE_SHORT_ARRAY = 0x55; 749 /** 750 * Followed by an 32-bit signed integer 751 */ 752 public static int TYPE_INT = 0x56; 753 /** 754 * An array of integers. Followed by first, a 16-bits integer for the number 755 * of integers and then, a list of 32-bit signed integers 756 */ 757 public static int TYPE_INT_ARRAY = 0x57; 758 /** 759 * Followed by an 64-bit signed integer 760 */ 761 public static int TYPE_LONG = 0x58; 762 /** 763 * An array of longs. Followed by first, a 16-bits integer for the number of 764 * longs and then, a list of 62-bit signed integers 765 */ 766 public static int TYPE_LONG_ARRAY = 0x59; 767 /** 768 * Followed by a single precision 32-bits floating point number 769 */ 770 public static int TYPE_FLOAT = 0x5a; 771 /** 772 * Array of double. Followed by first, a 16-bits integer for the number of 773 * floats and then, a list of 32-bit floats 774 */ 775 public static int TYPE_FLOAT_ARRAY = 0x5b; 776 /** 777 * Followed by a double precision 64-bits floating point number 778 */ 779 public static int TYPE_DOUBLE = 0x5c; 780 /** 781 * Array of double. Followed by first, a 16-bits integer for the number of 782 * doubles and then, a list of 64-bit doubles 783 */ 784 public static int TYPE_DOUBLE_ARRAY = 0x5d; 785 /** 786 * Array of characters. Followed by first, a 16-bits integer for the size in 787 * bytes (not in number of characters) of the string, then by the unicode 788 * string 789 */ 790 public static int TYPE_STRING = 0x5e; 791 /** 792 * Raw data, good for serialization. Followed by first, a 16-bits integer 793 * indicating the length in bytes of the dataset, and then the data itself. 794 */ 795 public static int TYPE_RAW = 0x5f; 796 797 /** 798 * An type-unspecified array. Followed by first, a 16-bits integer 799 * indicating the number of elements, and then, the elements themselves. The 800 * elements themselves have to give their type. 801 */ 802 public static byte TYPE_ARRAY = 0x60; 803 804 public static int TYPE_NULL = 0x61; 805 806 807 808 /** 809 * Constant that indicates that this message is a COMMAND, not and EVENT. 810 * 811 * For now it is followed by a string that has to be parssed at the application level. 812 * 813 * THIS IS EXPERIMENTAL AND MAY (WILL) CHANGE ! 814 */ 815 public static int COMMAND = 0x70; 816 817 818}