--- Begin Message ---
Did find two possibly solutions but I think difficult to implement



or






but on the second I see that every time the package is on another place.


So someone some tips how to implement one of the two ?

Roelof


Op 30-10-2019 om 12:20 schreef Roelof Wobben:
I did already and noticed that the text is changed.
and I noticed that the payload is only avaible at a link.

or if I made the node that sends is a Node and not a Workstation or  whatever because they do not store the payload somewhere.

Roelof


Op 30-10-2019 om 10:06 schreef Stéphane Ducasse:
Put a breakpoint.

What you are learning is how to help yourself and this is 80% of programming. 

S. 

On 30 Oct 2019, at 08:30, Roelof Wobben <r.wob...@home.nl> wrote:


From: Roelof Wobben <r.wob...@home.nl>
Subject: Re: [Pharo-users] help bij one of the last challenges of the chapterof network simulation of the oop book.
Date: 30 October 2019 at 08:30:14 CET
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>


Hello,

I solved that part but I wonder if  some one can give me a hint how I can read the package send from the server

consume seems to return a node and not a package.

Roelof




Op 30-10-2019 om 06:56 schreef Roelof Wobben:
Thanks,

That part I understand  but what I try  to say is that if I understand the code right the string BALL  is send back to the node that send the orginal messsgae #ball.  But as I said that one do not seem to recieve any packages and my question is still why ?

I debugged it several times but I do not see the reason.

Roelof



Op 30-10-2019 om 01:38 schreef Richard O'Keefe:
The first question you should ask is "What do I expect #ball asUppercase to be?"
The ANSI Smalltalk standard says
5.7.10.9 Message:  asUppercase
Synopsis
   Answer a new string which contains all of the elements of the
receiver converted to their upper
case equivalents.
Definition: <readableString>
   Answer a new string which contains all of the elements of the
receiver converted to their upper
case equivalents. Individual element of the string are converted as if
they were receivers of the
message #asUppercase.
Return Values
   <readableString> new
Errors
   none

Notice the word "string", the protocol "<readableString>", and the
entire absence of anything
suggesting that the receiver and result belong to the same class.

In my Smalltalk library, the receiver and result DO belong to the same class,
so #ball asUppercase ==> #BALL.
But the ANSI standard does not require that.
And I may change my library, because
GNU Smalltalk, Dolphin Smalltalk, Smalltalk/X, Squeak, and Pharo
all return a String.  (On the other hand, one reason I wrote my Smalltalk
was to press the edges of the ANSI standard, so maybe I'll leave it.)

So I think where you have #BALL you should have 'BALL'.
There may be other issues.

On Wed, 30 Oct 2019 at 11:00, Roelof Wobben via Pharo-users
<pharo-users@lists.pharo.org> wrote:
Hello,

I have to  made this challenge as last on of the OOP book

Servers answering requests

When a server node consumes a packet, it converts the payload to uppercase,
then sends that back to the sender of the request.

This is yet another subclass which redefines the consume: method, but this
time the node is stateless, so we have no initialization or accessor methods to
write:

KANetworkNode subclass: #KANetworkServer
instanceVariableNames: ''
classVariableNames: ''
category: 'NetworkSimulator-Nodes'

KANetworkServer >> consume: aPacket
| response |
response := aPacket payload asUppercase.
self send: (KANetworkPacket
from: self address
to: aPacket sourceAddress
payload: response)


Define a test for the behavior of server nodes.


I tried but I miss something

so far as I have this :

testSendToServer
     | packet ping pong link |
     packet := KANetworkPacket from: #ping to: #pong payload: #ball.
     ping := net nodeAt: #ping.
     pong := net nodeAt: #pong.
     link := net linkFrom: #ping to: #pong.
     ping send: packet.
     pong consume: packet.

but whatever I tried I cannot think of a test that works.

I tried

assert:  ping payload equals: #BALL
assert: ping arrievedpackages equals; 1

but they all fail

It looks like ping does not recieve the package back.

What do I do wrong or what can I test better ?

my code so far : https://github.com/RoelofWobben/network

and the problem is the testToServerTest that I cannot make work

Regards,

Roelof







--------------------------------------------
Stéphane Ducasse
03 59 35 87 52
Assistant: Julie Jonas 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
Villeneuve d'Ascq 59650
France




--- End Message ---

Reply via email to