2017 © Pedro Peláez
 

symfony-bundle socketserverbundle

image

marks12/socketserverbundle

  • Thursday, December 8, 2016
  • by marks12
  • Repository
  • 1 Watchers
  • 1 Stars
  • 83 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 19 Versions
  • 0 % Grown

The README.md

SocketServerBundle

Module allow open new multi-user socket server on port 10000 and call your class., (*1)

Installation

Install this module via composer, (*2)

composer require marks12/socketserverbundle, (*3)

Configure

add to config/config.yml, (*4)

marks12_socket_server:
    class:    'AppBundle\Socket\ResponseFactoryExample'
    address:    '0.0.0.0'
    port:       '10000'

Creating class

create class in your application AppBundle\Socket\ResponseFactoryExample.php, (*5)

<?php

namespace AppBundle\Socket;

class ResponseFactoryExample {

    function run ($data, $em, $answer_object) {

        $msg = 'Hello, this is class run in ServerProduct. Data: ' . 
        $data . 
        PHP_EOL;

        $answer_object->answer($msg);
    }
}

Using

Start your socket server, (*6)

bin/console marks12:socket:start, (*7)

Connect to server

telnet localhost 10000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome to server: Send exit for disconnect


test
Hello, this is class run in ServerProduct. Data: test
Hello, this is class run in ServerGhost. Data: test


exit
Connection closed by foreign host.

The Versions

08/12 2016