indexing description: "Wire message factory" license: "MIT license (see ../../license.txt)" author: "Beat Strasser " date: "$Date$" revision: "$Revision$" class P2P_WIRE_MESSAGE_CREATOR feature -- Access is_processable (format: STRING): BOOLEAN is -- Is format processable? require Format_valid: format /= Void do Result := format.is_equal (mimetype_binary) end Mimetype_binary: STRING is "application/x-jxta-msg" feature -- Basic operations create_from_message (format: STRING; message: P2P_MESSAGE): P2P_WIRE_MESSAGE is -- Create a wire message using given format require Format_valid: format /= Void and is_processable (format) Message_valid: message /= Void do create {P2P_WIRE_MESSAGE_BINARY} Result.make_from_message (message) ensure Result_set: Result /= Void end create_from_wire (format: STRING; medium: NETWORK_SOCKET; max_wait: INTEGER; checker: FUNCTION [ANY, TUPLE, BOOLEAN]): P2P_WIRE_MESSAGE is -- Create message parsed from wire using given format -- `checker' is a query function returning true whenever reading process should stop. require Format_valid: format /= Void and is_processable (format) Medium_valid: medium /= Void and medium.exists Timeout_valid: max_wait >= 0 do create {P2P_WIRE_MESSAGE_BINARY} Result.make_from_wire (medium, max_wait, checker) ensure Result_set: Result /= Void end end