123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- class Output {
- toServer(message) {
- //process.stdout.write(message);
- console.log(message);
- }
- toServerError(message, error) {
- //process.stderr.write(message);
- console.error(message, error, error.stack);
- }
- toMobile(mobileId, message, source) {
- var mobile = session.mobiles[mobileId];
- if(mobile == null || mobile == {}) {
- return;
- }
- if(source != null && Array.isArray(source)) {
- for(var i = 0; i < source.length; i++) {
- if(source[i].id == mobileId) {
- return;
- }
- }
- }
- mobile.mud_sendMessage(source, message);
- }
- toRoom(roomName, message, source) {
- var room = session.rooms[roomName];
- if(room == null || room == {}) {
- return;
- }
- for(var i = 0; i < room.mobiles.length; i++) {
- var mobileId = room.mobiles[i];
- if(source != null && source.id == mobileId) {
- continue;
- }
- this.toMobile(mobileId, message, source);
- }
- }
- matchesId(sources, id) {
- for(var i = 0; i < sources.length; i++) {
- if(sources[i].id == id) {
- return sources[i];
- }
- }
- return sources[0];
- }
- worldToMobiles(message, source) {
- for(var mobileId in session.mobiles) {
- var mobile = session.mobiles[mobileId];
- if(mobile == null || mobile == {}) {
- continue;
- }
- if(source != null && mobile.id === source.id) {
- continue;
- }
- this.toMobile(mobile.id, message, source);
- }
- }
- }
- module.exports = new Output();
|