Re: [Pharo-users] How to LAN feature

2018-05-13 Thread john pfersich
Oops, the -s flag doesn't work on Mac OS.

On Sun, May 13, 2018 at 7:41 PM, john pfersich  wrote:

> ​
> ​
> I don’t know if this will help, you can use OSProcess to run the ifconfig
> Unix (MAC OS) command, kind of like this:
>
> ​Use ifconfig -s to get a list of the interfaces:
>
> ​Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVRTX-OK TX-ERR TX-DRP
> TX-OVR Flg
> enp2s0 1500 0 0  0  0 0 0  0
> 0  0 BMU
> lo65536 0  1187  0  0 0  1187  0
> 0  0 LRU
> wlp3s0 1500 0  4943  0  0 0  2904  0
> 0  0 BMRU
>
> then:
> ​
> Ifconfig -a wlp3s0
>
> and get back something like this:
>
> wlp3s0Link encap:Ethernet  HWaddr 94:53:30:14:aa:6d
>   inet addr:192.168.0.14  Bcast:192.168.0.255  Mask:255.255.255.0
>   inet6 addr: fe80::21f3:b81d:eab3:f830/64 Scope:Link
>   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>   RX packets:4998 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:2904 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:1000
>   RX bytes:6864552 (6.8 MB)  TX bytes:295070 (295.0 KB)
>
> The second line has the host address and the broadcast address. I didn't
> say easy, I said possible. This works in Linux and MacOS. I dunno about MS
> Windows.
>
>
>
>
>
> Encrypted email at jgpfers...@protonmail.com
> Web: www.objectnets.net and www.objectnets.org
>
> On May 13, 2018, at 11:27, Julián Maestri  wrote:
>
> (impossible without the added networking prims, and still unreliable
>> whether it will find the correct ones with...)
>>
>
> The problem seems to be here: he->h_addr_list[0] its a list of addresses
> and only the first one is used.
>
> Unix: https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c
> 7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/unix/
> plugins/SocketPlugin/sqUnixSocket.c#L273
> Windows: https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c
> 7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/win32
> /plugins/SocketPlugin/sqWin32NewNet.c#L1843
> h_addr_list explanation: http://www.gnu.org/software/li
> bc/manual/html_node/Host-Names.html
>
> But changing that might affect the whole networking package, so i don't
> think it's going to be changed soon.
>
>
> On 13 May 2018 at 15:20, Hilaire  wrote:
>
>> I already tried the one you suggested, but it returns the loopback IP on
>> P7.
>>
>> With the Henrik SSDP package, I can get the IP:
>>
>> SSDPParticipant new allLocalV4Addresses.
>>
>> However when I activate a second network interface, this last one returns
>> an empty collection. When inactivating this second interface, it still
>> returns an empty collection...
>>
>> Hilaire
>>
>>
>> Le 13/05/2018 à 20:05, Julián Maestri a écrit :
>>
>>> NetNameResolver localHostAddress. "#[192 168 0 4]"
>>>
>>
>> --
>> Dr. Geo
>> http://drgeo.eu
>>
>>
>>
>>
>


Re: [Pharo-users] How to LAN feature

2018-05-13 Thread john pfersich
​
​
I don’t know if this will help, you can use OSProcess to run the ifconfig
Unix (MAC OS) command, kind of like this:

​Use ifconfig -s to get a list of the interfaces:

​Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVRTX-OK TX-ERR TX-DRP TX-OVR
Flg
enp2s0 1500 0 0  0  0 0 0  0
0  0 BMU
lo65536 0  1187  0  0 0  1187  0
0  0 LRU
wlp3s0 1500 0  4943  0  0 0  2904  0
0  0 BMRU

then:
​
Ifconfig -a wlp3s0

and get back something like this:

wlp3s0Link encap:Ethernet  HWaddr 94:53:30:14:aa:6d
  inet addr:192.168.0.14  Bcast:192.168.0.255  Mask:255.255.255.0
  inet6 addr: fe80::21f3:b81d:eab3:f830/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:4998 errors:0 dropped:0 overruns:0 frame:0
  TX packets:2904 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:6864552 (6.8 MB)  TX bytes:295070 (295.0 KB)

The second line has the host address and the broadcast address. I didn't
say easy, I said possible. This works in Linux and MacOS. I dunno about MS
Windows.





Encrypted email at jgpfers...@protonmail.com
Web: www.objectnets.net and www.objectnets.org

On May 13, 2018, at 11:27, Julián Maestri  wrote:

(impossible without the added networking prims, and still unreliable
> whether it will find the correct ones with...)
>

The problem seems to be here: he->h_addr_list[0] its a list of addresses
and only the first one is used.

Unix: https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c
7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/
unix/plugins/SocketPlugin/sqUnixSocket.c#L273
Windows: https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c
7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/
win32/plugins/SocketPlugin/sqWin32NewNet.c#L1843
h_addr_list explanation: http://www.gnu.org/software/li
bc/manual/html_node/Host-Names.html

But changing that might affect the whole networking package, so i don't
think it's going to be changed soon.


On 13 May 2018 at 15:20, Hilaire  wrote:

> I already tried the one you suggested, but it returns the loopback IP on
> P7.
>
> With the Henrik SSDP package, I can get the IP:
>
> SSDPParticipant new allLocalV4Addresses.
>
> However when I activate a second network interface, this last one returns
> an empty collection. When inactivating this second interface, it still
> returns an empty collection...
>
> Hilaire
>
>
> Le 13/05/2018 à 20:05, Julián Maestri a écrit :
>
>> NetNameResolver localHostAddress. "#[192 168 0 4]"
>>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>


Re: [Pharo-users] How to LAN feature

2018-05-13 Thread Julián Maestri
>
> (impossible without the added networking prims, and still unreliable
> whether it will find the correct ones with...)
>

The problem seems to be here: he->h_addr_list[0] its a list of addresses
and only the first one is used.

Unix:
https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c#L273
Windows:
https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c#L1843
h_addr_list explanation:
http://www.gnu.org/software/libc/manual/html_node/Host-Names.html

But changing that might affect the whole networking package, so i don't
think it's going to be changed soon.


On 13 May 2018 at 15:20, Hilaire  wrote:

> I already tried the one you suggested, but it returns the loopback IP on
> P7.
>
> With the Henrik SSDP package, I can get the IP:
>
> SSDPParticipant new allLocalV4Addresses.
>
> However when I activate a second network interface, this last one returns
> an empty collection. When inactivating this second interface, it still
> returns an empty collection...
>
> Hilaire
>
>
> Le 13/05/2018 à 20:05, Julián Maestri a écrit :
>
>> NetNameResolver localHostAddress. "#[192 168 0 4]"
>>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>


Re: [Pharo-users] How to LAN feature

2018-05-13 Thread Hilaire

I already tried the one you suggested, but it returns the loopback IP on P7.

With the Henrik SSDP package, I can get the IP:

SSDPParticipant new allLocalV4Addresses.

However when I activate a second network interface, this last one 
returns an empty collection. When inactivating this second interface, it 
still returns an empty collection...


Hilaire


Le 13/05/2018 à 20:05, Julián Maestri a écrit :

NetNameResolver localHostAddress. "#[192 168 0 4]"


--
Dr. Geo
http://drgeo.eu





Re: [Pharo-users] How to LAN feature

2018-05-13 Thread Julián Maestri
I think he means you can not discover all interfaces from Pharo. I have 2
network interfaces with addresses 192.168.0.4 and 192.168.56.1
Pharo only returns the first one.

NetNameResolver localHostName  "'thepc'".
NetNameResolver localHostAddress. "#[192 168 0 4]"
NetNameResolver nameForAddress:  #[192 168 0 4] timeout: 60. "'thepc'"

NetNameResolver nameForAddress:  #[192 168 56 1] timeout: 60. "'thepc'"

If you need to broadcast something on the second one, you have no way to
automatically discover it. (eg if you wanted to prompt the user which one
to broadcast to, or to broadcast on them all)

On 13 May 2018 at 14:50, Hilaire  wrote:

> Hi Norbert,
>
> Just to be sure I understood correctly what you wrote regarding network
> interface: Do you mean it is impossible to discover the network interface
> IP address from the image? It is this IP the teacher Dr. Geo server needs
> to broadcast over UDP.
>
> Hilaire
>
>
> Le 08/05/2018 à 16:22, Henrik Sperre Johansen a écrit :
>
>> mDNS and SSDP are pretty much interchangeable, implementation wise;)
>>
>> The main problem; most computers these days come with multiple networking
>> interfaces, and are usually connected to separate subnets.
>> So when you connect a socket to the broadcast address, you have no idea
>> which interface it will actually send the request over, and whether you
>> can
>> communicate with other entities is sort if hit or miss.
>>
>> Pharos netresolver is blissfully unaware/unable to tell you which
>> interfaces
>> are available,
>> most of the work in the SSDP implementation went into trying to detect all
>> the different ones (impossible without the added networking prims, and
>> still
>> unreliable whether it will find the correct ones with...), and bind:'ing a
>> socket to each specifically.
>>
>> IIRC, the default server/client instantiation exemplified in class
>> comments
>> now simply binds to 0:0:0:0 and hopes the default interface is what you
>> wanted,  SSDPServer>>onAllInterfacesOfferServiceType:atLocation: runs
>> through the more extensive setup.
>>
>> Cheers,
>> Henry
>>
>> P.S. In second place; a listener loop capable of error handling a spotty
>> wifi connection/machine sleep cycles...
>>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>


Re: [Pharo-users] How to LAN feature

2018-05-13 Thread Hilaire

Hi Norbert,

Just to be sure I understood correctly what you wrote regarding network 
interface: Do you mean it is impossible to discover the network 
interface IP address from the image? It is this IP the teacher Dr. Geo 
server needs to broadcast over UDP.


Hilaire


Le 08/05/2018 à 16:22, Henrik Sperre Johansen a écrit :

mDNS and SSDP are pretty much interchangeable, implementation wise;)

The main problem; most computers these days come with multiple networking
interfaces, and are usually connected to separate subnets.
So when you connect a socket to the broadcast address, you have no idea
which interface it will actually send the request over, and whether you can
communicate with other entities is sort if hit or miss.

Pharos netresolver is blissfully unaware/unable to tell you which interfaces
are available,
most of the work in the SSDP implementation went into trying to detect all
the different ones (impossible without the added networking prims, and still
unreliable whether it will find the correct ones with...), and bind:'ing a
socket to each specifically.

IIRC, the default server/client instantiation exemplified in class comments
now simply binds to 0:0:0:0 and hopes the default interface is what you
wanted,  SSDPServer>>onAllInterfacesOfferServiceType:atLocation: runs
through the more extensive setup.

Cheers,
Henry

P.S. In second place; a listener loop capable of error handling a spotty
wifi connection/machine sleep cycles...


--
Dr. Geo
http://drgeo.eu





Re: [Pharo-users] Package extension. Adding instance variables to classes

2018-05-13 Thread Herbert Vojčík



Guillermo Polito wrote:
Just be careful, that privateState thing looks like a Moose only Famix 
feature. It't not available in plain Pharo objects :)


In ES6 mailing list, they had this problem re how to do private state 
for objects, and it was shown that having private state is sort of 
isomorphic to having WeakMap indexed by objects. So in case of Pharo, 
I'd say using WeakIdentitityKeyDictionary can do the trick. Without 
resorting to any external dependency.


Herby

On Wed, May 9, 2018 at 2:09 AM, Alidra Abdelghani via Pharo-users 
mailto:pharo-users@lists.pharo.org>> wrote:




-- Forwarded message --
From: Alidra Abdelghani mailto:alidran...@yahoo.fr>>
To: Pavel Krivanek mailto:pavel.kriva...@gmail.com>>
Cc: Any question about pharo is welcome mailto:pharo-users@lists.pharo.org>>
Bcc:
Date: Wed, 9 May 2018 01:09:06 +0100
Subject: Re: Package extension. Adding instance variables to classes
Hi Pavel,

Thank you for your answer.
I actually didn’t know about this mechanism.
I think it is will do the job :)
  I have probably to rewrite some parts pf my code to access my
variables through privateState.  no?


Thanks again
Abdelghani

On 07 May 2018, at 13:15, pharo-users-requ...@lists.pharo.org
 wrote:


Message: 1
Date: Mon, 7 May 2018 13:43:56 +0200
From: Pavel Krivanek mailto:pavel.kriva...@gmail.com>>
To: Any question about pharo is welcome
mailto:pharo-users@lists.pharo.org>>
Subject: Re: [Pharo-users] Package extension. Adding instance
variables to classes
Message-ID:
mailto:CAHN2FzeMiBL4Y8asJ0XCjS2AQdxycoN+pbc+Hsd=trmnmui...@mail.gmail.com>>
Content-Type: text/plain; charset="utf-8"

2018-05-07 12:25 GMT+02:00 Alidra Abdelghani via Pharo-users <
pharo-users@lists.pharo.org >:




-- P?eposlan? zpr?va --
From: Alidra Abdelghani mailto:alidran...@yahoo.fr>>
To:pharo-users@lists.pharo.org 
Cc:
Bcc:
Date: Mon, 7 May 2018 11:25:49 +0100
Subject: Package extension. Adding instance variables to classes
Hi,

I am working on a package named ClassNamesAnalyzer and I need to
add code
to third party classes in other packages (for instance the FAMIX-Core
package).
?Extending? third party classes with methods is easy; I just need to
categorise my methods under the *ClassNamesAnalyzer protocole so that
loading my package will load them in the image.
However, if I want to add instance variables to theses classes,
they are
not there when I load the package in a new image.

*So my question is* : is there a way to include instance variables
addition to other packages in my package?



Currently not, you should use privateState



*Another question is* : is it good practice to add instance
variables to
classes in third party packages and is there a way to avoid it
(because I
am not very confortable with that idea)?



It is not, see FAMIXContainerEntity>>#definedAnnotationTypes how
this issue
is currently being solved using the privateState.

Cheers,
-- Pavel




Thanks in advance,
Abdelghani







--



Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - _http://www.cnrs.fr_


*Web:* _http://guillep.github.io_

*Phone: *+33 06 52 70 66 13





Re: [Pharo-users] How to add item to world menu

2018-05-13 Thread Cyril Ferlicot
On dim. 13 mai 2018 at 18:23, chrismihaylyk  wrote:

> Hi!
>
> I need to add an item to world menu. I know how to add it manually by
> running some method.
> But I need this item to be added automatically into world menu just along
> installing (loading) package code from smalltalkhub.


Hello,

This is done via the "worldMenu" pragma.

Browse the senders of #worldMenu and you will see how this is done.



>
> Can anyone help me, please? =)
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
> --
Cyril Ferlicot
https://ferlicot.fr


[Pharo-users] How to add item to world menu

2018-05-13 Thread chrismihaylyk
Hi!

I need to add an item to world menu. I know how to add it manually by
running some method. 
But I need this item to be added automatically into world menu just along
installing (loading) package code from smalltalkhub.

Can anyone help me, please? =)



--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html