Test :: PoE :: Server :: TCP

Un componente PoE che fornisce servizi server TCP per casi di test
Scarica ora

Test :: PoE :: Server :: TCP Classifica e riepilogo

Annuncio pubblicitario

  • Rating:
  • Licenza:
  • Perl Artistic License
  • Prezzo:
  • FREE
  • Nome editore:
  • Chris Williams
  • Sito web dell'editore:
  • http://search.cpan.org/~bingos/

Test :: PoE :: Server :: TCP Tag


Test :: PoE :: Server :: TCP Descrizione

Un componente PoE che fornisce servizi server TCP per casi di test Il modulo TEST :: POE :: Server :: TCP è un componente PoE che fornisce un framework del server TCP per l'inclusione nei casi di test del componente client, invece di dover rotolare il proprio.Unizione registrata con il componente, una sessione riceverà eventi correlati al client collega, disconnetti, ingresso e uscita flocata. Ciascuno di questi eventi si riferirà a un ID client unico che può essere utilizzato nella comunicazione con il componente quando si inviano dati al client o scollegando un collegamento client.Synopsisa server Echo molto semplice con la registrazione di richieste di ciascun client: utilizzare rigoroso; usa Poe; Usa Test :: PoE :: Server :: TCP; POE :: Session-> Crea (Pacchetti_state => ,]; $ poe_kernel-> run (); uscita 0; SUB _START {# spawn il test :: poe :: server del server :: TCP. $ _ -> {Testd} = Test :: POE :: Server :: TCP-> Spawn (indirizzo => '127.0.0.1', porto => 0,); Restituzione; } sub testd_connected {my ($ heap, $ id) = @_ ; # A Client collegato L'ID univoco è in arg. # Crea un arrayRef vuoto per questo client su * il nostro * heap $ heap -> {client} -> {$ ID} = []; Restituzione; } sub testd_client_input {my ($ kernel, $ heap, $ mittener, $ id, $ ingresso) = @_ ; # Il client ci ha inviato una riga di ingresso # consente di archiviarlo push @ {$ heap -> {client} -> {$ ID}, $ INPUT; # Okay, siamo un server Echo, quindi consente di inviarlo al client # conosciamo il mittente, quindi può sempre ottenere l'oggetto server. My $ TestD = $ mittente-> get_heap (); $ Testd-> send_to_client ($ ID, $ INPUT); # O anche # $ mittente-> get_heap () -> send_to_client ($ ID, $ INPUT); # In alternativa, potremmo semplicemente tornare al mittente # $ kernel-> post ($ mittente, 'send_to_client', $ ID, $ INPUT); Restituzione; } Sub TestD_Disconnected {My ($ Heap, $ ID) = @_ ; # Client disconnesso per qualsiasi motivo # dobbiamo liberare il nostro archiviazione Elimina $ heap -> {client} -> {$ ID}; Restituzione; } Uso del modulo in un testcase: utilizzare rigoroso; Usa Test :: altro; Utilizzare POE QW (ruota: SocketFactory Wheel :: ReadWrite Filter :: Linea); Usa Test :: PoE :: Server :: TCP; Plan Test => 5; My @Data = ('Questo è un test "," Questo è un altro test "," Questo è l'ultimo test ",); POE :: Sessioni-> Crea (pacchetti_state => ],], heap => {data => \ @Data,},); $ poe_kernel-> run (); uscita 0; sub _start {$ _ -> {Testd} = Test :: PoE :: Server :: TCP-> SPAWN (indirizzo => '127.0.0.1', PORTA => 0,); Restituzione; } Sub TestD_Revigatod {My ($ Heap, $ Object) = @_ ; $ heap -> {port} = $ Object-> Porto (); $ heap -> {fabbrica} = poe :: wheel :: schocketfactory-> new (remoteaddress => '127.0.0.1', remoteport => $ heap -> {port}, successevent => '_sock_up', failureevent => ' _sock_fail ',); Restituzione; } sub _sock_up {my ($ heap, $ socket) = @_ ; Elimina $ heap -> {fabbrica}; $ heap -> {socket} = poe :: wheel :: readwrite-> nuovo (maniglia => $ presa, inputEvent => '_sock_in', ercersevent => '_sock_err',); $ heap -> {socket} -> inserisci ($ heap -> {data} -> ); Restituzione; } sub _sock_fail {My $ heap = $ _ ; Elimina $ heap -> {fabbrica}; $ heap -> {Testd} -> spegnimento (); Restituzione; } sub _sock_in {my ($ heap, $ ingresso) = @_ ; My $ Data = Shift @ {$ heap -> {data}}; OK ($ Input EQ $ Data, 'Data abbinati'); A meno che (scalare @ {$ heap -> {data}}) {elimina $ heap -> {socket}; Restituzione; } $ heap -> {socket} -> put ($ heap -> {data} -> ); Restituzione; } sub _sock_err {elimina $ _ -> {socket}; Restituzione; } Sub TestD_Connected {My ($ Heap, $ stato, $ ID) = @_ ; pass ($ stato); Restituzione; } sub testd_disconnected {pass ($ _ ); $ poe_kernel-> post ($ _ , 'spegnimento'); Restituzione; } sub testd_client_input {my ($ mittener, $ id, $ ingresso) = @_ ; My $ TestD = $ _ -> get_heap (); $ Testd-> send_to_client ($ ID, $ INPUT); Restituzione; } Requisiti: · Perl.


Test :: PoE :: Server :: TCP Software correlato