Skip to content

Commit

Permalink
[SRE] Correcting bug preventing ParticpantLeft to be fired in the def…
Browse files Browse the repository at this point in the history
…ault space of the default context

The particular case of the default space of the default context haven't
been managed, since it is the first space created its parent.
  • Loading branch information
ngaud committed Feb 13, 2020
1 parent 4c9d8fa commit 2c49996
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Expand Up @@ -132,7 +132,7 @@ class SpaceParticipantEventEmitter implements SpaceParticipantListener {

val logger : Logger

val defaultSpace : EventSpace
var defaultSpace : EventSpace

new (defaultSpace : EventSpace, logger : Logger) {
this.defaultSpace = defaultSpace
Expand Down Expand Up @@ -160,7 +160,11 @@ class SpaceParticipantEventEmitter implements SpaceParticipantListener {
this.defaultSpace.emit(null, new ParticipantLeft(addr, participantAddr.spaceID))
}
}


def setDefaultSpace(^space : EventSpace) {
this.defaultSpace = ^space
}

}

/** Factory for a space participant event emitter.
Expand Down
@@ -1,17 +1,17 @@
/*
/*
* $Id$
*
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
*
* Copyright (C) 2014-2020 the original authors or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,6 +20,7 @@
*/
package io.sarl.sre.spaces

import io.sarl.lang.core.EventSpace
import java.util.EventListener

/**
Expand Down Expand Up @@ -47,4 +48,11 @@ interface SpaceParticipantListener extends EventListener {
*/
def participantLeft(participant : Participant)

/**
* Set the default only useful for the first space to be created
*
* @param space - the default space of the default context
*/
def setDefaultSpace(^space : EventSpace)

}
Expand Up @@ -73,6 +73,9 @@ abstract class AbstractSreEventSpaceSpecification {
protected def createSpaceInstance(id : SpaceID, params : Object*) : OpenLocalEventSpace {
val listener = this.spaceParticipantListenerFactory.create(this.defaultSpace, this.logger.kernelLogger)
val ^space = new OpenLocalEventSpace(id, listener, this.logger)
if (this.defaultSpace === null) {//Only useful for the default space of the default context
listener.defaultSpace = ^space;
}
this.injector.injectMembers(^space)
return ^space
}
Expand Down

0 comments on commit 2c49996

Please sign in to comment.