Initial Commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>processing-net</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,295 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=36
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=1
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1
|
||||
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=2
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=80
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=2
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_processing
|
||||
formatter_settings_version=12
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="Processing Net Library" default="build">
|
||||
|
||||
<target name="clean" description="Clean the build directories">
|
||||
<delete dir="bin" />
|
||||
<delete file="library/net.jar" />
|
||||
</target>
|
||||
|
||||
<target name="compile" description="Compile sources">
|
||||
<condition property="core-built">
|
||||
<available file="../../../core/library/core.jar" />
|
||||
</condition>
|
||||
<fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/library/core.jar" />
|
||||
|
||||
<mkdir dir="bin" />
|
||||
<javac source="1.8"
|
||||
target="1.8"
|
||||
srcdir="src" destdir="bin"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
classpath="../../../core/library/core.jar"
|
||||
nowarn="true"
|
||||
compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
|
||||
<compilerclasspath path="../../mode/org.eclipse.jdt.core.jar;
|
||||
../../mode/jdtCompilerAdapter.jar" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="compile" description="Build net library">
|
||||
<jar basedir="bin" destfile="library/net.jar" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Chat Server
|
||||
* by Tom Igoe.
|
||||
*
|
||||
* Press the mouse to stop the server.
|
||||
*/
|
||||
|
||||
|
||||
import processing.net.*;
|
||||
|
||||
int port = 10002;
|
||||
boolean myServerRunning = true;
|
||||
int bgColor = 0;
|
||||
int direction = 1;
|
||||
int textLine = 60;
|
||||
|
||||
Server myServer;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(400, 400);
|
||||
textFont(createFont("SanSerif", 16));
|
||||
myServer = new Server(this, port); // Starts a myServer on port 10002
|
||||
background(0);
|
||||
}
|
||||
|
||||
void mousePressed()
|
||||
{
|
||||
// If the mouse clicked the myServer stops
|
||||
myServer.stop();
|
||||
myServerRunning = false;
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (myServerRunning == true)
|
||||
{
|
||||
text("server", 15, 45);
|
||||
Client thisClient = myServer.available();
|
||||
if (thisClient != null) {
|
||||
if (thisClient.available() > 0) {
|
||||
text("mesage from: " + thisClient.ip() + " : " + thisClient.readString(), 15, textLine);
|
||||
textLine = textLine + 35;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text("server", 15, 45);
|
||||
text("stopped", 15, 65);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* HTTP Client.
|
||||
*
|
||||
* Starts a network client that connects to a server on port 80,
|
||||
* sends an HTTP 1.0 GET request, and prints the results.
|
||||
*
|
||||
* Note that this code is not necessary for simple HTTP GET request:
|
||||
* Simply calling loadStrings("http://www.processing.org") would do
|
||||
* the same thing as (and more efficiently than) this example.
|
||||
* This example is for people who might want to do something more
|
||||
* complicated later.
|
||||
*/
|
||||
|
||||
|
||||
import processing.net.*;
|
||||
|
||||
Client c;
|
||||
String data;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(50);
|
||||
fill(200);
|
||||
c = new Client(this, "www.ucla.edu", 80); // Connect to server on port 80
|
||||
c.write("GET / HTTP/1.0\r\n"); // Use the HTTP "GET" command to ask for a Web page
|
||||
c.write("\r\n");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
if (c.available() > 0) { // If there's incoming data from the client...
|
||||
data = c.readString(); // ...then grab it and print it
|
||||
println(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Shared Drawing Canvas (Client)
|
||||
* by Alexander R. Galloway.
|
||||
*
|
||||
* The Processing Client class is instantiated by specifying a remote
|
||||
* address and port number to which the socket connection should be made.
|
||||
* Once the connection is made, the client may read (or write) data to the server.
|
||||
* Before running this program, start the Shared Drawing Canvas (Server) program.
|
||||
*/
|
||||
|
||||
|
||||
import processing.net.*;
|
||||
|
||||
Client c;
|
||||
String input;
|
||||
int data[];
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(450, 255);
|
||||
background(204);
|
||||
stroke(0);
|
||||
frameRate(5); // Slow it down a little
|
||||
// Connect to the server's IP address and port
|
||||
c = new Client(this, "127.0.0.1", 12345); // Replace with your server's IP and port
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (mousePressed == true) {
|
||||
// Draw our line
|
||||
stroke(255);
|
||||
line(pmouseX, pmouseY, mouseX, mouseY);
|
||||
// Send mouse coords to other person
|
||||
c.write(pmouseX + " " + pmouseY + " " + mouseX + " " + mouseY + "\n");
|
||||
}
|
||||
// Receive data from server
|
||||
if (c.available() > 0) {
|
||||
input = c.readString();
|
||||
input = input.substring(0, input.indexOf("\n")); // Only up to the newline
|
||||
data = int(split(input, ' ')); // Split values into an array
|
||||
// Draw line using received coords
|
||||
stroke(0);
|
||||
line(data[0], data[1], data[2], data[3]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Shared Drawing Canvas (Server)
|
||||
* by Alexander R. Galloway.
|
||||
*
|
||||
* A server that shares a drawing canvas between two computers.
|
||||
* In order to open a socket connection, a server must select a
|
||||
* port on which to listen for incoming clients and through which
|
||||
* to communicate. Once the socket is established, a client may
|
||||
* connect to the server and send or receive commands and data.
|
||||
* Get this program running and then start the Shared Drawing
|
||||
* Canvas (Client) program so see how they interact.
|
||||
*/
|
||||
|
||||
|
||||
import processing.net.*;
|
||||
|
||||
Server s;
|
||||
Client c;
|
||||
String input;
|
||||
int data[];
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(450, 255);
|
||||
background(204);
|
||||
stroke(0);
|
||||
frameRate(5); // Slow it down a little
|
||||
s = new Server(this, 12345); // Start a simple server on a port
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (mousePressed == true) {
|
||||
// Draw our line
|
||||
stroke(255);
|
||||
line(pmouseX, pmouseY, mouseX, mouseY);
|
||||
// Send mouse coords to other person
|
||||
s.write(pmouseX + " " + pmouseY + " " + mouseX + " " + mouseY + "\n");
|
||||
}
|
||||
// Receive data from client
|
||||
c = s.available();
|
||||
if (c != null) {
|
||||
input = c.readString();
|
||||
input = input.substring(0, input.indexOf("\n")); // Only up to the newline
|
||||
data = int(split(input, ' ')); // Split values into an array
|
||||
// Draw line using received coords
|
||||
stroke(0);
|
||||
line(data[0], data[1], data[2], data[3]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
name = Network
|
||||
version = 1
|
||||
Binary file not shown.
@@ -0,0 +1,690 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Client - basic network client implementation
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-2007 Ben Fry and Casey Reas
|
||||
The previous version of this code was developed by Hernando Barragan
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.net;
|
||||
import processing.core.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client.xml )
|
||||
*
|
||||
* A client connects to a server and sends data back and forth. If anything
|
||||
* goes wrong with the connection, for example the host is not there or is
|
||||
* listening on a different port, an exception is thrown.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref net
|
||||
* @brief The client class is used to create client Objects which connect to a server to exchange data.
|
||||
* @instanceName client any variable of type Client
|
||||
* @usage Application
|
||||
* @see_external LIB_net/clientEvent
|
||||
*/
|
||||
public class Client implements Runnable {
|
||||
PApplet parent;
|
||||
Method clientEventMethod;
|
||||
Method disconnectEventMethod;
|
||||
|
||||
Thread thread;
|
||||
Socket socket;
|
||||
int port;
|
||||
String host;
|
||||
|
||||
public InputStream input;
|
||||
public OutputStream output;
|
||||
|
||||
byte buffer[] = new byte[32768];
|
||||
int bufferIndex;
|
||||
int bufferLast;
|
||||
|
||||
boolean disposeRegistered = false;
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param host address of the server
|
||||
* @param port port to read/write from on the server
|
||||
*/
|
||||
public Client(PApplet parent, String host, int port) {
|
||||
this.parent = parent;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
|
||||
try {
|
||||
socket = new Socket(this.host, this.port);
|
||||
input = socket.getInputStream();
|
||||
output = socket.getOutputStream();
|
||||
|
||||
thread = new Thread(this);
|
||||
thread.start();
|
||||
|
||||
parent.registerMethod("dispose", this);
|
||||
disposeRegistered = true;
|
||||
|
||||
// reflection to check whether host sketch has a call for
|
||||
// public void clientEvent(processing.net.Client)
|
||||
// which would be called each time an event comes in
|
||||
try {
|
||||
clientEventMethod =
|
||||
parent.getClass().getMethod("clientEvent",
|
||||
new Class[] { Client.class });
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
}
|
||||
// do the same for disconnectEvent(Client c);
|
||||
try {
|
||||
disconnectEventMethod =
|
||||
parent.getClass().getMethod("disconnectEvent",
|
||||
new Class[] { Client.class });
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
}
|
||||
|
||||
} catch (ConnectException ce) {
|
||||
ce.printStackTrace();
|
||||
dispose();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param socket any object of type Socket
|
||||
* @throws IOException
|
||||
*/
|
||||
public Client(PApplet parent, Socket socket) throws IOException {
|
||||
this.parent = parent;
|
||||
this.socket = socket;
|
||||
|
||||
input = socket.getInputStream();
|
||||
output = socket.getOutputStream();
|
||||
|
||||
thread = new Thread(this);
|
||||
thread.start();
|
||||
|
||||
// reflection to check whether host sketch has a call for
|
||||
// public void disconnectEvent(processing.net.Client)
|
||||
try {
|
||||
disconnectEventMethod =
|
||||
parent.getClass().getMethod("disconnectEvent",
|
||||
new Class[] { Client.class });
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_stop.xml )
|
||||
*
|
||||
* Disconnects from the server. Use to shut the connection when you're
|
||||
* finished with the Client.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @brief Disconnects from the server
|
||||
* @usage application
|
||||
*/
|
||||
public void stop() {
|
||||
if (disconnectEventMethod != null && thread != null){
|
||||
try {
|
||||
disconnectEventMethod.invoke(parent, new Object[] { this });
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
disconnectEventMethod = null;
|
||||
}
|
||||
}
|
||||
if (disposeRegistered) {
|
||||
parent.unregisterMethod("dispose", this);
|
||||
disposeRegistered = false;
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disconnect from the server: internal use only.
|
||||
* <P>
|
||||
* This should only be called by the internal functions in PApplet,
|
||||
* use stop() instead from within your own applets.
|
||||
*/
|
||||
public void dispose() {
|
||||
thread = null;
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
input = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
output = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
socket = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
while (Thread.currentThread() == thread) {
|
||||
try {
|
||||
while (input != null) {
|
||||
int value;
|
||||
|
||||
// try to read a byte using a blocking read.
|
||||
// An exception will occur when the sketch is exits.
|
||||
try {
|
||||
value = input.read();
|
||||
} catch (SocketException e) {
|
||||
System.err.println("Client SocketException: " + e.getMessage());
|
||||
// the socket had a problem reading so don't try to read from it again.
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// read returns -1 if end-of-stream occurs (for example if the host disappears)
|
||||
if (value == -1) {
|
||||
System.err.println("Client got end-of-stream.");
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (buffer) {
|
||||
// todo: at some point buffer should stop increasing in size,
|
||||
// otherwise it could use up all the memory.
|
||||
if (bufferLast == buffer.length) {
|
||||
byte temp[] = new byte[bufferLast << 1];
|
||||
System.arraycopy(buffer, 0, temp, 0, bufferLast);
|
||||
buffer = temp;
|
||||
}
|
||||
buffer[bufferLast++] = (byte)value;
|
||||
}
|
||||
|
||||
// now post an event
|
||||
if (clientEventMethod != null) {
|
||||
try {
|
||||
clientEventMethod.invoke(parent, new Object[] { this });
|
||||
} catch (Exception e) {
|
||||
System.err.println("error, disabling clientEvent() for " + host);
|
||||
e.printStackTrace();
|
||||
clientEventMethod = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//errorMessage("run", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_active.xml )
|
||||
*
|
||||
* Returns true if this client is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @brief Returns true if this client is still active
|
||||
* @usage application
|
||||
*/
|
||||
public boolean active() {
|
||||
return (thread != null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_ip.xml )
|
||||
*
|
||||
* Returns the IP address of the computer to which the Client is attached.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Returns the IP address of the machine as a String
|
||||
*/
|
||||
public String ip() {
|
||||
if (socket != null){
|
||||
return socket.getInetAddress().getHostAddress();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_available.xml )
|
||||
*
|
||||
* Returns the number of bytes available. When any client has bytes
|
||||
* available from the server, it returns the number of bytes.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Returns the number of bytes in the buffer waiting to be read
|
||||
*/
|
||||
public int available() {
|
||||
return (bufferLast - bufferIndex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_clear.xml )
|
||||
*
|
||||
* Empty the buffer, removes all the data stored there.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Clears the buffer
|
||||
*/
|
||||
public void clear() {
|
||||
bufferLast = 0;
|
||||
bufferIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_read.xml )
|
||||
*
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in
|
||||
* the buffer. Returns -1 if there is no byte, although this should be
|
||||
* avoided by first cheacking <b>available()</b> to see if any data is available.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Returns a value from the buffer
|
||||
*/
|
||||
public int read() {
|
||||
if (bufferIndex == bufferLast) return -1;
|
||||
|
||||
synchronized (buffer) {
|
||||
int outgoing = buffer[bufferIndex++] & 0xff;
|
||||
if (bufferIndex == bufferLast) { // rewind
|
||||
bufferIndex = 0;
|
||||
bufferLast = 0;
|
||||
}
|
||||
return outgoing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_readChar.xml )
|
||||
*
|
||||
* Returns the next byte in the buffer as a char. Returns -1 or 0xffff if
|
||||
* nothing is there.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Returns the next byte in the buffer as a char
|
||||
*/
|
||||
public char readChar() {
|
||||
if (bufferIndex == bufferLast) return (char)(-1);
|
||||
return (char) read();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_readBytes.xml )
|
||||
*
|
||||
* Reads a group of bytes from the buffer. The version with no parameters
|
||||
* returns a byte array of all data in the buffer. This is not efficient,
|
||||
* but is easy to use. The version with the <b>byteBuffer</b> parameter is
|
||||
* more memory and time efficient. It grabs the data in the buffer and puts
|
||||
* it into the byte array passed in and returns an int value for the number
|
||||
* of bytes read. If more bytes are available than can fit into the
|
||||
* <b>byteBuffer</b>, only those that fit are read.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* <h3>Advanced</h3>
|
||||
* Return a byte array of anything that's in the serial buffer.
|
||||
* Not particularly memory/speed efficient, because it creates
|
||||
* a byte array on each read, but it's easier to use than
|
||||
* readBytes(byte b[]) (see below).
|
||||
*
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Reads everything in the buffer
|
||||
*/
|
||||
public byte[] readBytes() {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
|
||||
synchronized (buffer) {
|
||||
int length = bufferLast - bufferIndex;
|
||||
byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
return outgoing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
* Return a byte array of anything that's in the serial buffer
|
||||
* up to the specified maximum number of bytes.
|
||||
* Not particularly memory/speed efficient, because it creates
|
||||
* a byte array on each read, but it's easier to use than
|
||||
* readBytes(byte b[]) (see below).
|
||||
*
|
||||
* @param max the maximum number of bytes to read
|
||||
*/
|
||||
public byte[] readBytes(int max) {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
|
||||
synchronized (buffer) {
|
||||
int length = bufferLast - bufferIndex;
|
||||
if (length > max) length = max;
|
||||
byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
if (bufferIndex == bufferLast) {
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
}
|
||||
|
||||
return outgoing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
* Grab whatever is in the serial buffer, and stuff it into a
|
||||
* byte buffer passed in by the user. This is more memory/time
|
||||
* efficient than readBytes() returning a byte[] array.
|
||||
*
|
||||
* Returns an int for how many bytes were read. If more bytes
|
||||
* are available than can fit into the byte array, only those
|
||||
* that will fit are read.
|
||||
*
|
||||
* @param bytebuffer passed in byte array to be altered
|
||||
*/
|
||||
public int readBytes(byte bytebuffer[]) {
|
||||
if (bufferIndex == bufferLast) return 0;
|
||||
|
||||
synchronized (buffer) {
|
||||
int length = bufferLast - bufferIndex;
|
||||
if (length > bytebuffer.length) length = bytebuffer.length;
|
||||
System.arraycopy(buffer, bufferIndex, bytebuffer, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
if (bufferIndex == bufferLast) {
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_readBytesUntil.xml )
|
||||
*
|
||||
* Reads from the port into a buffer of bytes up to and including a
|
||||
* particular character. If the character isn't in the buffer, 'null' is
|
||||
* returned. The version with no <b>byteBuffer</b> parameter returns a byte
|
||||
* array of all data up to and including the <b>interesting</b> byte. This
|
||||
* is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs
|
||||
* the data in the buffer and puts it into the byte array passed in and
|
||||
* returns an int value for the number of bytes read. If the byte buffer is
|
||||
* not large enough, -1 is returned and an error is printed to the message
|
||||
* area. If nothing is in the buffer, 0 is returned.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Reads from the buffer of bytes up to and including a particular character
|
||||
* @param interesting character designated to mark the end of the data
|
||||
*/
|
||||
public byte[] readBytesUntil(int interesting) {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
byte what = (byte)interesting;
|
||||
|
||||
synchronized (buffer) {
|
||||
int found = -1;
|
||||
for (int k = bufferIndex; k < bufferLast; k++) {
|
||||
if (buffer[k] == what) {
|
||||
found = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) return null;
|
||||
|
||||
int length = found - bufferIndex + 1;
|
||||
byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
if (bufferIndex == bufferLast) {
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
}
|
||||
return outgoing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
* Reads from the serial port into a buffer of bytes until a
|
||||
* particular character. If the character isn't in the serial
|
||||
* buffer, then 'null' is returned.
|
||||
*
|
||||
* If outgoing[] is not big enough, then -1 is returned,
|
||||
* and an error message is printed on the console.
|
||||
* If nothing is in the buffer, zero is returned.
|
||||
* If 'interesting' byte is not in the buffer, then 0 is returned.
|
||||
*
|
||||
* @param byteBuffer passed in byte array to be altered
|
||||
*/
|
||||
public int readBytesUntil(int interesting, byte byteBuffer[]) {
|
||||
if (bufferIndex == bufferLast) return 0;
|
||||
byte what = (byte)interesting;
|
||||
|
||||
synchronized (buffer) {
|
||||
int found = -1;
|
||||
for (int k = bufferIndex; k < bufferLast; k++) {
|
||||
if (buffer[k] == what) {
|
||||
found = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) return 0;
|
||||
|
||||
int length = found - bufferIndex + 1;
|
||||
if (length > byteBuffer.length) {
|
||||
System.err.println("readBytesUntil() byte buffer is" +
|
||||
" too small for the " + length +
|
||||
" bytes up to and including char " + interesting);
|
||||
return -1;
|
||||
}
|
||||
//byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, byteBuffer, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
if (bufferIndex == bufferLast) {
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_readString.xml )
|
||||
*
|
||||
* Returns the all the data from the buffer as a String. This method
|
||||
* assumes the incoming characters are ASCII. If you want to transfer
|
||||
* Unicode data, first convert the String to a byte stream in the
|
||||
* representation of your choice (i.e. UTF8 or two-byte Unicode data), and
|
||||
* send it as a byte array.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Returns the buffer as a String
|
||||
*/
|
||||
public String readString() {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
return new String(readBytes());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_readStringUntil.xml )
|
||||
*
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns
|
||||
* <b>null</b> if it doesn't find what you're looking for.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* <h3>Advanced</h3>
|
||||
* <p/>
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
*
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Returns the buffer as a String up to and including a particular character
|
||||
* @param interesting character designated to mark the end of the data
|
||||
*/
|
||||
public String readStringUntil(int interesting) {
|
||||
byte b[] = readBytesUntil(interesting);
|
||||
if (b == null) return null;
|
||||
return new String(b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Client_write.xml )
|
||||
*
|
||||
* Writes data to a server specified when constructing the client.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref client:client
|
||||
* @usage application
|
||||
* @brief Writes bytes, chars, ints, bytes[], Strings
|
||||
* @param data data to write
|
||||
*/
|
||||
public void write(int data) { // will also cover char
|
||||
try {
|
||||
output.write(data & 0xff); // for good measure do the &
|
||||
output.flush(); // hmm, not sure if a good idea
|
||||
|
||||
} catch (Exception e) { // null pointer or serial port dead
|
||||
//errorMessage("write", e);
|
||||
//e.printStackTrace();
|
||||
//dispose();
|
||||
//disconnect(e);
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void write(byte data[]) {
|
||||
try {
|
||||
output.write(data);
|
||||
output.flush(); // hmm, not sure if a good idea
|
||||
|
||||
} catch (Exception e) { // null pointer or serial port dead
|
||||
//errorMessage("write", e);
|
||||
//e.printStackTrace();
|
||||
//disconnect(e);
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
* Write a String to the output. Note that this doesn't account
|
||||
* for Unicode (two bytes per char), nor will it send UTF8
|
||||
* characters.. It assumes that you mean to send a byte buffer
|
||||
* (most often the case for networking and serial i/o) and
|
||||
* will only use the bottom 8 bits of each char in the string.
|
||||
* (Meaning that internally it uses String.getBytes)
|
||||
*
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
*/
|
||||
public void write(String data) {
|
||||
write(data.getBytes());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle disconnect due to an Exception being thrown.
|
||||
*/
|
||||
/*
|
||||
protected void disconnect(Exception e) {
|
||||
dispose();
|
||||
if (e != null) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* General error reporting, all corralled here just in case
|
||||
* I think of something slightly more intelligent to do.
|
||||
*/
|
||||
//public void errorMessage(String where, Exception e) {
|
||||
//parent.die("Error inside Client." + where + "()", e);
|
||||
//e.printStackTrace(System.err);
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Server - basic network server implementation
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-2007 Ben Fry and Casey Reas
|
||||
The previous version of this code was developed by Hernando Barragan
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.net;
|
||||
|
||||
import processing.core.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Server.xml )
|
||||
*
|
||||
* A server sends and receives data to and from its associated clients
|
||||
* (other programs connected to it). When a server is started, it begins
|
||||
* listening for connections on the port specified by the <b>port</b>
|
||||
* parameter. Computers have many ports for transferring data and some are
|
||||
* commonly used so be sure to not select one of these. For example, web
|
||||
* servers usually use port 80 and POP mail uses port 110.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref net
|
||||
* @usage application
|
||||
* @brief The server class is used to create server objects which send and receives data to and from its associated clients (other programs connected to it).
|
||||
* @instanceName server any variable of type Server
|
||||
*/
|
||||
public class Server implements Runnable {
|
||||
PApplet parent;
|
||||
Method serverEventMethod;
|
||||
|
||||
Thread thread;
|
||||
ServerSocket server;
|
||||
int port;
|
||||
|
||||
/** Number of clients currently connected. */
|
||||
public int clientCount;
|
||||
/** Array of client objects, useful length is determined by clientCount. */
|
||||
public Client[] clients;
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param port port used to transfer data
|
||||
*/
|
||||
public Server(PApplet parent, int port) {
|
||||
this(parent, port, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param port port used to transfer data
|
||||
* @param host when multiple NICs are in use, the ip (or name) to bind from
|
||||
*/
|
||||
public Server(PApplet parent, int port, String host) {
|
||||
this.parent = parent;
|
||||
this.port = port;
|
||||
|
||||
try {
|
||||
if (host == null) {
|
||||
server = new ServerSocket(this.port);
|
||||
} else {
|
||||
server = new ServerSocket(this.port, 10, InetAddress.getByName(host));
|
||||
}
|
||||
//clients = new Vector();
|
||||
clients = new Client[10];
|
||||
|
||||
thread = new Thread(this);
|
||||
thread.start();
|
||||
|
||||
parent.registerMethod("dispose", this);
|
||||
|
||||
// reflection to check whether host applet has a call for
|
||||
// public void serverEvent(Server s, Client c);
|
||||
// which is called when a new guy connects
|
||||
try {
|
||||
serverEventMethod =
|
||||
parent.getClass().getMethod("serverEvent",
|
||||
new Class[] { Server.class,
|
||||
Client.class });
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
thread = null;
|
||||
throw new RuntimeException(e);
|
||||
//errorMessage("<init>", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Server_disconnect.xml )
|
||||
*
|
||||
* Disconnect a particular client.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @brief Disconnect a particular client.
|
||||
* @webref server:server
|
||||
* @param client the client to disconnect
|
||||
*/
|
||||
public void disconnect(Client client) {
|
||||
client.stop();
|
||||
int index = clientIndex(client);
|
||||
if (index != -1) {
|
||||
removeIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void removeIndex(int index) {
|
||||
clientCount--;
|
||||
// shift down the remaining clients
|
||||
for (int i = index; i < clientCount; i++) {
|
||||
clients[i] = clients[i+1];
|
||||
}
|
||||
// mark last empty var for garbage collection
|
||||
clients[clientCount] = null;
|
||||
}
|
||||
|
||||
|
||||
protected void disconnectAll() {
|
||||
synchronized (clients) {
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
try {
|
||||
clients[i].stop();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
clients[i] = null;
|
||||
}
|
||||
clientCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void addClient(Client client) {
|
||||
if (clientCount == clients.length) {
|
||||
clients = (Client[]) PApplet.expand(clients);
|
||||
}
|
||||
clients[clientCount++] = client;
|
||||
}
|
||||
|
||||
|
||||
protected int clientIndex(Client client) {
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
if (clients[i] == client) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Server_active.xml )
|
||||
*
|
||||
* Returns true if this server is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref server:server
|
||||
* @brief Return true if this server is still active.
|
||||
*/
|
||||
public boolean active() {
|
||||
return thread != null;
|
||||
}
|
||||
|
||||
|
||||
static public String ip() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// the last index used for available. can't just cycle through
|
||||
// the clients in order from 0 each time, because if client 0 won't
|
||||
// shut up, then the rest of the clients will never be heard from.
|
||||
int lastAvailable = -1;
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Server_available.xml )
|
||||
*
|
||||
* Returns the next client in line with a new message.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @brief Returns the next client in line with a new message.
|
||||
* @webref server
|
||||
* @usage application
|
||||
*/
|
||||
public Client available() {
|
||||
synchronized (clients) {
|
||||
int index = lastAvailable + 1;
|
||||
if (index >= clientCount) index = 0;
|
||||
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
int which = (index + i) % clientCount;
|
||||
Client client = clients[which];
|
||||
//Check for valid client
|
||||
if (!client.active()){
|
||||
removeIndex(which); //Remove dead client
|
||||
i--; //Don't skip the next client
|
||||
//If the client has data make sure lastAvailable
|
||||
//doesn't end up skipping the next client
|
||||
which--;
|
||||
//fall through to allow data from dead clients
|
||||
//to be retreived.
|
||||
}
|
||||
if (client.available() > 0) {
|
||||
lastAvailable = which;
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Server_stop.xml )
|
||||
*
|
||||
* Disconnects all clients and stops the server.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* <h3>Advanced</h3>
|
||||
* Use this to shut down the server if you finish using it while your applet
|
||||
* is still running. Otherwise, it will be automatically be shut down by the
|
||||
* host PApplet using dispose(), which is identical.
|
||||
* @brief Disconnects all clients and stops the server.
|
||||
* @webref server
|
||||
* @usage application
|
||||
*/
|
||||
public void stop() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disconnect all clients and stop the server: internal use only.
|
||||
*/
|
||||
public void dispose() {
|
||||
thread = null;
|
||||
|
||||
if (clients != null) {
|
||||
disconnectAll();
|
||||
clientCount = 0;
|
||||
clients = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (server != null) {
|
||||
server.close();
|
||||
server = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
while (Thread.currentThread() == thread) {
|
||||
try {
|
||||
Socket socket = server.accept();
|
||||
Client client = new Client(parent, socket);
|
||||
synchronized (clients) {
|
||||
addClient(client);
|
||||
if (serverEventMethod != null) {
|
||||
try {
|
||||
serverEventMethod.invoke(parent, new Object[] { this, client });
|
||||
} catch (Exception e) {
|
||||
System.err.println("Disabling serverEvent() for port " + port);
|
||||
e.printStackTrace();
|
||||
serverEventMethod = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
//thrown when server.close() is called and server is waiting on accept
|
||||
System.err.println("Server SocketException: " + e.getMessage());
|
||||
thread = null;
|
||||
} catch (IOException e) {
|
||||
//errorMessage("run", e);
|
||||
e.printStackTrace();
|
||||
thread = null;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(8);
|
||||
} catch (InterruptedException ex) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ( begin auto-generated from Server_write.xml )
|
||||
*
|
||||
* Writes a value to all the connected clients. It sends bytes out from the
|
||||
* Server object.
|
||||
*
|
||||
* ( end auto-generated )
|
||||
* @webref server
|
||||
* @brief Writes data to all connected clients
|
||||
* @param data data to write
|
||||
*/
|
||||
public void write(int data) { // will also cover char
|
||||
int index = 0;
|
||||
while (index < clientCount) {
|
||||
if (clients[index].active()) {
|
||||
clients[index].write(data);
|
||||
index++;
|
||||
} else {
|
||||
removeIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void write(byte data[]) {
|
||||
int index = 0;
|
||||
while (index < clientCount) {
|
||||
if (clients[index].active()) {
|
||||
clients[index].write(data);
|
||||
index++;
|
||||
} else {
|
||||
removeIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void write(String data) {
|
||||
int index = 0;
|
||||
while (index < clientCount) {
|
||||
if (clients[index].active()) {
|
||||
clients[index].write(data);
|
||||
index++;
|
||||
} else {
|
||||
removeIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user