pomelo-protobuf
Advanced tools
| { | ||
| "ls": { | ||
| "message MS": { | ||
| "optional Status status": 2, | ||
| "message Status": { | ||
| "repeated string table_cards": 13 | ||
| } | ||
| }, | ||
| "required MS s": 1 | ||
| } | ||
| } |
| { | ||
| "ls": { | ||
| "message MS": { | ||
| "optional Status status": 2, | ||
| "message Status": { | ||
| "repeated int32 table_cards": 13 | ||
| } | ||
| }, | ||
| "required MS s": 1 | ||
| } | ||
| } |
| var protobuf = require('../../lib/client/protobuf'); | ||
| var encoder = protobuf.encoder; | ||
| var decoder = protobuf.decoder; | ||
| var codec = protobuf.codec; | ||
| var parser = require('../../lib/parser'); | ||
| var util = require('../../lib/util'); | ||
| var should = require('should'); | ||
| var tc = require('../rootMsgTC'); | ||
| describe('msgEncoderTest', function(){ | ||
| var protos = parser.parse(require('../rootMsg.json')); | ||
| protobuf.init({encoderProtos:protos, decoderProtos:protos}); | ||
| describe('protobufTest', function(){ | ||
| for(var route in tc){ | ||
| var msg = tc[route]; | ||
| console.log('===================='); | ||
| console.log(route); | ||
| var buffer = protobuf.encode(route, msg); | ||
| console.log(msg); | ||
| console.log(buffer.length); | ||
| var decodeMsg = protobuf.decode(route, buffer); | ||
| console.log(decodeMsg); | ||
| console.log('===================='); | ||
| util.equal(msg, decodeMsg).should.equal(true); | ||
| } | ||
| }); | ||
| }); |
| { | ||
| "lv": { | ||
| "s": { | ||
| "option": "repeated", | ||
| "type": "LevelUpMessage", | ||
| "tag": 1 | ||
| }, | ||
| "__messages": { | ||
| "LevelUpMessage": { | ||
| "userid": { | ||
| "option": "required", | ||
| "type": "string", | ||
| "tag": 1 | ||
| }, | ||
| "delta_xp": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 2 | ||
| }, | ||
| "level": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 3 | ||
| }, | ||
| "level_up": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 4 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "userid", | ||
| "2": "delta_xp", | ||
| "3": "level", | ||
| "4": "level_up" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "s" | ||
| } | ||
| }, | ||
| "ls": { | ||
| "s": { | ||
| "option": "required", | ||
| "type": "MS", | ||
| "tag": 1 | ||
| }, | ||
| "__messages": { | ||
| "MS": { | ||
| "events": { | ||
| "option": "repeated", | ||
| "type": "Event", | ||
| "tag": 1 | ||
| }, | ||
| "status": { | ||
| "option": "optional", | ||
| "type": "Status", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": { | ||
| "Status": { | ||
| "status": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 1 | ||
| }, | ||
| "max_player": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 2 | ||
| }, | ||
| "big_blind": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 3 | ||
| }, | ||
| "max_cash": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 4 | ||
| }, | ||
| "buy_in": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 5 | ||
| }, | ||
| "is_sit_and_go": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 6 | ||
| }, | ||
| "dealerindex": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 7 | ||
| }, | ||
| "index": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 8 | ||
| }, | ||
| "turnNumber": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 9 | ||
| }, | ||
| "bet": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 10 | ||
| }, | ||
| "min_bet": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 11 | ||
| }, | ||
| "this_turn_start_index": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 12 | ||
| }, | ||
| "table_cards": { | ||
| "option": "repeated", | ||
| "type": "int32", | ||
| "tag": 13 | ||
| }, | ||
| "potindex": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 14 | ||
| }, | ||
| "pots": { | ||
| "option": "repeated", | ||
| "type": "Pot", | ||
| "tag": 15 | ||
| }, | ||
| "userdec": { | ||
| "option": "repeated", | ||
| "type": "Player", | ||
| "tag": 16 | ||
| }, | ||
| "animation_time": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 17 | ||
| }, | ||
| "speed": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 18 | ||
| }, | ||
| "__messages": { | ||
| "Pot": { | ||
| "cash": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 1 | ||
| }, | ||
| "winner": { | ||
| "option": "repeated", | ||
| "type": "Winner", | ||
| "tag": 2 | ||
| }, | ||
| "userinpot": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 3 | ||
| }, | ||
| "__messages": { | ||
| "Winner": { | ||
| "userid": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 6 | ||
| }, | ||
| "hand": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 7 | ||
| }, | ||
| "pokers": { | ||
| "option": "repeated", | ||
| "type": "int32", | ||
| "tag": 8 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "6": "userid", | ||
| "7": "hand", | ||
| "8": "pokers" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "cash", | ||
| "2": "winner", | ||
| "3": "userinpot" | ||
| } | ||
| }, | ||
| "Player": { | ||
| "userid": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 1 | ||
| }, | ||
| "username": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 2 | ||
| }, | ||
| "isstandup": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 3 | ||
| }, | ||
| "level": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 4 | ||
| }, | ||
| "canplay": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 5 | ||
| }, | ||
| "isplay": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 6 | ||
| }, | ||
| "is_on_table": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 7 | ||
| }, | ||
| "isallin": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 8 | ||
| }, | ||
| "card1": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 9 | ||
| }, | ||
| "card2": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 10 | ||
| }, | ||
| "turn": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 11 | ||
| }, | ||
| "bet": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 12 | ||
| }, | ||
| "money": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 13 | ||
| }, | ||
| "chair_index": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 14 | ||
| }, | ||
| "avatar_index": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 15 | ||
| }, | ||
| "chipcount": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 16 | ||
| }, | ||
| "action": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 17 | ||
| }, | ||
| "gift": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 18 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "userid", | ||
| "2": "username", | ||
| "3": "isstandup", | ||
| "4": "level", | ||
| "5": "canplay", | ||
| "6": "isplay", | ||
| "7": "is_on_table", | ||
| "8": "isallin", | ||
| "9": "card1", | ||
| "10": "card2", | ||
| "11": "turn", | ||
| "12": "bet", | ||
| "13": "money", | ||
| "14": "chair_index", | ||
| "15": "avatar_index", | ||
| "16": "chipcount", | ||
| "17": "action", | ||
| "18": "gift" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "status", | ||
| "2": "max_player", | ||
| "3": "big_blind", | ||
| "4": "max_cash", | ||
| "5": "buy_in", | ||
| "6": "is_sit_and_go", | ||
| "7": "dealerindex", | ||
| "8": "index", | ||
| "9": "turnNumber", | ||
| "10": "bet", | ||
| "11": "min_bet", | ||
| "12": "this_turn_start_index", | ||
| "13": "table_cards", | ||
| "14": "potindex", | ||
| "15": "pots", | ||
| "16": "userdec", | ||
| "17": "animation_time", | ||
| "18": "speed" | ||
| } | ||
| }, | ||
| "Event": { | ||
| "id": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 1 | ||
| }, | ||
| "user": { | ||
| "option": "optional", | ||
| "type": "Player1", | ||
| "tag": 2 | ||
| }, | ||
| "chair_index": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 3 | ||
| }, | ||
| "bet": { | ||
| "option": "repeated", | ||
| "type": "Bet", | ||
| "tag": 4 | ||
| }, | ||
| "small_bet": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 5 | ||
| }, | ||
| "user_id": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 6 | ||
| }, | ||
| "card1": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 7 | ||
| }, | ||
| "card2": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 8 | ||
| }, | ||
| "rank": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 9 | ||
| }, | ||
| "chips": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 10 | ||
| }, | ||
| "showhand": { | ||
| "option": "repeated", | ||
| "type": "string", | ||
| "tag": 11 | ||
| }, | ||
| "friendid": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 12 | ||
| }, | ||
| "giftid": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 13 | ||
| }, | ||
| "__messages": { | ||
| "Player1": { | ||
| "userid": { | ||
| "option": "required", | ||
| "type": "string", | ||
| "tag": 1 | ||
| }, | ||
| "username": { | ||
| "option": "required", | ||
| "type": "string", | ||
| "tag": 2 | ||
| }, | ||
| "isstandup": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 3 | ||
| }, | ||
| "level": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 4 | ||
| }, | ||
| "canplay": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 5 | ||
| }, | ||
| "isplay": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 6 | ||
| }, | ||
| "is_on_table": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 7 | ||
| }, | ||
| "isallin": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 8 | ||
| }, | ||
| "card1": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 9 | ||
| }, | ||
| "card2": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 10 | ||
| }, | ||
| "turn": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 11 | ||
| }, | ||
| "bet": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 12 | ||
| }, | ||
| "money": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 13 | ||
| }, | ||
| "chair_index": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 14 | ||
| }, | ||
| "avatar_index": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 15 | ||
| }, | ||
| "chipcount": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 16 | ||
| }, | ||
| "action": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 17 | ||
| }, | ||
| "gift": { | ||
| "option": "optional", | ||
| "type": "int32", | ||
| "tag": 18 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "userid", | ||
| "2": "username", | ||
| "3": "isstandup", | ||
| "4": "level", | ||
| "5": "canplay", | ||
| "6": "isplay", | ||
| "7": "is_on_table", | ||
| "8": "isallin", | ||
| "9": "card1", | ||
| "10": "card2", | ||
| "11": "turn", | ||
| "12": "bet", | ||
| "13": "money", | ||
| "14": "chair_index", | ||
| "15": "avatar_index", | ||
| "16": "chipcount", | ||
| "17": "action", | ||
| "18": "gift" | ||
| } | ||
| }, | ||
| "Bet": { | ||
| "chair_index": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 1 | ||
| }, | ||
| "bet": { | ||
| "option": "required", | ||
| "type": "int32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "chair_index", | ||
| "2": "bet" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "id", | ||
| "2": "user", | ||
| "3": "chair_index", | ||
| "4": "bet", | ||
| "5": "small_bet", | ||
| "6": "user_id", | ||
| "7": "card1", | ||
| "8": "card2", | ||
| "9": "rank", | ||
| "10": "chips", | ||
| "11": "showhand", | ||
| "12": "friendid", | ||
| "13": "giftid" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "events", | ||
| "2": "status" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "s" | ||
| } | ||
| } | ||
| } |
| { | ||
| "message Path": { | ||
| "x": { | ||
| "option": "required", | ||
| "type": "double", | ||
| "tag": 1 | ||
| }, | ||
| "y": { | ||
| "option": "required", | ||
| "type": "double", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "x", | ||
| "2": "y" | ||
| } | ||
| }, | ||
| "message Map": { | ||
| "name": { | ||
| "option": "required", | ||
| "type": "string", | ||
| "tag": 1 | ||
| }, | ||
| "width": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "height": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 3 | ||
| }, | ||
| "tileW": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 4 | ||
| }, | ||
| "tileH": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 5 | ||
| }, | ||
| "weightMap": { | ||
| "option": "repeated", | ||
| "type": "Collisions", | ||
| "tag": 6 | ||
| }, | ||
| "__messages": { | ||
| "Collisions": { | ||
| "collisions": { | ||
| "option": "repeated", | ||
| "type": "Collison", | ||
| "tag": 1 | ||
| }, | ||
| "__messages": { | ||
| "Collison": { | ||
| "start": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "length": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "start", | ||
| "2": "length" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "collisions" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "name", | ||
| "2": "width", | ||
| "3": "height", | ||
| "4": "tileW", | ||
| "5": "tileH", | ||
| "6": "weightMap" | ||
| } | ||
| }, | ||
| "message Item": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "kindId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "kindId" | ||
| } | ||
| }, | ||
| "message Equipment": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "kindId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "kindId" | ||
| } | ||
| }, | ||
| "message Entities": { | ||
| "item": { | ||
| "option": "repeated", | ||
| "type": "Item", | ||
| "tag": 1 | ||
| }, | ||
| "equipment": { | ||
| "option": "repeated", | ||
| "type": "Equipment", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "item", | ||
| "2": "equipment" | ||
| } | ||
| }, | ||
| "onMove": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "path": { | ||
| "option": "repeated", | ||
| "type": "Path", | ||
| "tag": 2 | ||
| }, | ||
| "speed": { | ||
| "option": "required", | ||
| "type": "float", | ||
| "tag": 3 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "path", | ||
| "3": "speed" | ||
| } | ||
| }, | ||
| "area.playerHandler.enterScene": { | ||
| "entities": { | ||
| "option": "optional", | ||
| "type": "Entities", | ||
| "tag": 1 | ||
| }, | ||
| "curPlayer": { | ||
| "option": "optional", | ||
| "type": "Player", | ||
| "tag": 2 | ||
| }, | ||
| "map": { | ||
| "option": "required", | ||
| "type": "Map", | ||
| "tag": 3 | ||
| }, | ||
| "__messages": { | ||
| "Player": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "kindId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "bag": { | ||
| "option": "required", | ||
| "type": "Bag", | ||
| "tag": 3 | ||
| }, | ||
| "equipments": { | ||
| "option": "repeated", | ||
| "type": "Equipment", | ||
| "tag": 4 | ||
| }, | ||
| "__messages": { | ||
| "Bag": { | ||
| "items": { | ||
| "option": "repeated", | ||
| "type": "Item", | ||
| "tag": 1 | ||
| }, | ||
| "__messages": { | ||
| "Item": { | ||
| "id": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "type": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "id", | ||
| "2": "type" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "items" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "kindId", | ||
| "3": "bag", | ||
| "4": "equipments" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "entities", | ||
| "2": "curPlayer", | ||
| "3": "map" | ||
| } | ||
| } | ||
| } |
| { | ||
| "onMove": { | ||
| "entityId": 14, | ||
| "path": [ | ||
| { | ||
| "x": 128, | ||
| "y": 796 | ||
| }, | ||
| { | ||
| "x": 677, | ||
| "y": 895 | ||
| } | ||
| ], | ||
| "speed": 160 | ||
| }, | ||
| "area.playerHandler.enterScene": { | ||
| "entities": { | ||
| "item": [ | ||
| { | ||
| "entityId": 1, | ||
| "kindId": 1001 | ||
| }, | ||
| { | ||
| "entityId": 2, | ||
| "kindId": 1002 | ||
| } | ||
| ], | ||
| "equipment": [ | ||
| { | ||
| "entityId": 1, | ||
| "kindId": 2001 | ||
| }, | ||
| { | ||
| "entityId": 2, | ||
| "kindId": 2002 | ||
| } | ||
| ] | ||
| }, | ||
| "curPlayer": { | ||
| "entityId": 1, | ||
| "kindId": 3001, | ||
| "bag": { | ||
| "items": [ | ||
| { | ||
| "id": 1, | ||
| "type": "pomelo" | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "type": "protobuf" | ||
| } | ||
| ] | ||
| }, | ||
| "equipments": [ | ||
| { | ||
| "entityId": 1, | ||
| "kindId": 2001 | ||
| }, | ||
| { | ||
| "entityId": 2, | ||
| "kindId": 2002 | ||
| } | ||
| ] | ||
| }, | ||
| "map": { | ||
| "name": "a", | ||
| "width": 10, | ||
| "height": 10, | ||
| "tileW": 5, | ||
| "tileH": 5, | ||
| "weightMap": [ | ||
| { | ||
| "collisions": [] | ||
| }, | ||
| { | ||
| "collisions": [] | ||
| }, | ||
| { | ||
| "collisions": [ | ||
| { | ||
| "start": 1, | ||
| "length": 3 | ||
| }, | ||
| { | ||
| "start": 79, | ||
| "length": 3 | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "collisions": [ | ||
| { | ||
| "start": 27, | ||
| "length": 2 | ||
| }, | ||
| { | ||
| "start": 78, | ||
| "length": 4 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } |
| { | ||
| "onMove": { | ||
| "entityId": 14, | ||
| "path": [{ | ||
| "x": 128, | ||
| "y": 796 | ||
| }, { | ||
| "x": 677, | ||
| "y": 895 | ||
| }], | ||
| "speed": 160 | ||
| }, | ||
| "area.playerHandler.enterScene": { | ||
| "entities": { | ||
| "item": [{ | ||
| "entityId": 1, | ||
| "kindId": 1001 | ||
| }, { | ||
| "entityId": 2, | ||
| "kindId": 1002 | ||
| }], | ||
| "equipment": [{ | ||
| "entityId": 1, | ||
| "kindId": 2001 | ||
| }, { | ||
| "entityId": 2, | ||
| "kindId": 2002 | ||
| }] | ||
| }, | ||
| "curPlayer": { | ||
| "entityId": 1, | ||
| "kindId": 3001, | ||
| "bag": { | ||
| "items": [{ | ||
| "id": 1, | ||
| "type": "pomelo" | ||
| }, { | ||
| "id": 2, | ||
| "type": "protobuf" | ||
| }] | ||
| }, | ||
| "equipments": [{ | ||
| "entityId": 1, | ||
| "kindId": 2001 | ||
| }, { | ||
| "entityId": 2, | ||
| "kindId": 2002 | ||
| }] | ||
| }, | ||
| "map": { | ||
| "name": "a", | ||
| "width": 10, | ||
| "height": 10, | ||
| "tileW": 5, | ||
| "tileH": 5, | ||
| "weightMap": [{ | ||
| "collisions": [] | ||
| }, { | ||
| "collisions": [] | ||
| }, { | ||
| "collisions": [{ | ||
| "start": 1, | ||
| "length": 3 | ||
| }, { | ||
| "start": 79, | ||
| "length": 3 | ||
| }] | ||
| }, { | ||
| "collisions": [{ | ||
| "start": 27, | ||
| "length": 2 | ||
| }, { | ||
| "start": 78, | ||
| "length": 4 | ||
| }] | ||
| }] | ||
| } | ||
| } | ||
| } |
| var tc = module.exports; | ||
| tc.onMove = { | ||
| 'entityId':14, | ||
| 'path' : [{'x':128,'y':796},{'x':677,'y':895}], | ||
| 'speed':160 | ||
| }; | ||
| tc['area.playerHandler.enterScene'] = { | ||
| entities : { | ||
| item : [ | ||
| { | ||
| entityId : 1, | ||
| kindId : 1001 | ||
| }, | ||
| { | ||
| entityId : 2, | ||
| kindId : 1002 | ||
| } | ||
| ], | ||
| equipment : [ | ||
| { | ||
| entityId : 1, | ||
| kindId : 2001 | ||
| }, | ||
| { | ||
| entityId : 2, | ||
| kindId : 2002 | ||
| } | ||
| ] | ||
| }, | ||
| curPlayer : { | ||
| entityId : 1, | ||
| kindId : 3001, | ||
| bag : { | ||
| items : [ | ||
| { | ||
| id : 1, | ||
| type : 'pomelo' | ||
| }, | ||
| { | ||
| id : 2, | ||
| type : 'protobuf' | ||
| } | ||
| ] | ||
| }, | ||
| equipments : [ | ||
| { | ||
| entityId : 1, | ||
| kindId : 2001 | ||
| }, | ||
| { | ||
| entityId : 2, | ||
| kindId : 2002 | ||
| } | ||
| ] | ||
| }, | ||
| map : { | ||
| name : 'a', | ||
| width : 10, | ||
| height : 10, | ||
| tileW : 5, | ||
| tileH : 5, | ||
| weightMap:[ | ||
| {'collisions':[]}, | ||
| {'collisions':[]}, | ||
| {'collisions':[ | ||
| {'start':1,'length':3}, | ||
| {'start':79,'length':3} | ||
| ]}, | ||
| {'collisions':[ | ||
| {'start':27,'length':2}, | ||
| {'start':78,'length':4} | ||
| ]} | ||
| ] | ||
| } | ||
| }; |
| var protobuf = require('../lib/protobuf'); | ||
| var util = require('../lib/util'); | ||
| var should = require('should'); | ||
| var tc = require('./rootMsgTC'); | ||
| var fs = require('fs'); | ||
| fs.writeFileSync('rootMSG.json', JSON.stringify(tc)); | ||
| describe('msgEncoderTest', function(){ | ||
| var protos = protobuf.parse(require('./rootMsg.json')); | ||
| // console.log(protos); | ||
| protobuf.init({encoderProtos:protos, decoderProtos:protos}); | ||
| describe('encodeTest', function(){ | ||
| // console.log('%j', tc); | ||
| for(var route in tc){ | ||
| var msg = tc[route]; | ||
| console.log('===================='); | ||
| console.log(route); | ||
| var buffer = protobuf.encode(route, msg); | ||
| console.log(msg); | ||
| console.log(buffer.length); | ||
| // console.log(buffer); | ||
| var decodeMsg = protobuf.decode(route, buffer); | ||
| console.log(decodeMsg); | ||
| console.log('===================='); | ||
| util.equal(msg, decodeMsg).should.equal(true); | ||
| } | ||
| }); | ||
| }); |
| { | ||
| "message Path": { | ||
| "x": { | ||
| "option": "required", | ||
| "type": "double", | ||
| "tag": 1 | ||
| }, | ||
| "y": { | ||
| "option": "required", | ||
| "type": "double", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "x", | ||
| "2": "y" | ||
| } | ||
| }, | ||
| "message Map": { | ||
| "name": { | ||
| "option": "required", | ||
| "type": "string", | ||
| "tag": 1 | ||
| }, | ||
| "width": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "height": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 3 | ||
| }, | ||
| "tileW": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 4 | ||
| }, | ||
| "tileH": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 5 | ||
| }, | ||
| "weightMap": { | ||
| "option": "repeated", | ||
| "type": "Collisions", | ||
| "tag": 6 | ||
| }, | ||
| "__messages": { | ||
| "Collisions": { | ||
| "collisions": { | ||
| "option": "repeated", | ||
| "type": "Collison", | ||
| "tag": 1 | ||
| }, | ||
| "__messages": { | ||
| "Collison": { | ||
| "start": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "length": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "start", | ||
| "2": "length" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "collisions" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "name", | ||
| "2": "width", | ||
| "3": "height", | ||
| "4": "tileW", | ||
| "5": "tileH", | ||
| "6": "weightMap" | ||
| } | ||
| }, | ||
| "message Item": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "kindId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "kindId" | ||
| } | ||
| }, | ||
| "message Equipment": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "kindId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "kindId" | ||
| } | ||
| }, | ||
| "message Entities": { | ||
| "item": { | ||
| "option": "repeated", | ||
| "type": "Item", | ||
| "tag": 1 | ||
| }, | ||
| "equipment": { | ||
| "option": "repeated", | ||
| "type": "Equipment", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "item", | ||
| "2": "equipment" | ||
| } | ||
| }, | ||
| "onMove": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "path": { | ||
| "option": "repeated", | ||
| "type": "Path", | ||
| "tag": 2 | ||
| }, | ||
| "speed": { | ||
| "option": "required", | ||
| "type": "float", | ||
| "tag": 3 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "path", | ||
| "3": "speed" | ||
| } | ||
| }, | ||
| "area.playerHandler.enterScene": { | ||
| "entities": { | ||
| "option": "optional", | ||
| "type": "Entities", | ||
| "tag": 1 | ||
| }, | ||
| "curPlayer": { | ||
| "option": "optional", | ||
| "type": "Player", | ||
| "tag": 2 | ||
| }, | ||
| "map": { | ||
| "option": "required", | ||
| "type": "Map", | ||
| "tag": 3 | ||
| }, | ||
| "__messages": { | ||
| "Player": { | ||
| "entityId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "kindId": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 2 | ||
| }, | ||
| "bag": { | ||
| "option": "required", | ||
| "type": "Bag", | ||
| "tag": 3 | ||
| }, | ||
| "equipments": { | ||
| "option": "repeated", | ||
| "type": "Equipment", | ||
| "tag": 4 | ||
| }, | ||
| "__messages": { | ||
| "Bag": { | ||
| "items": { | ||
| "option": "repeated", | ||
| "type": "Item", | ||
| "tag": 1 | ||
| }, | ||
| "__messages": { | ||
| "Item": { | ||
| "id": { | ||
| "option": "required", | ||
| "type": "uInt32", | ||
| "tag": 1 | ||
| }, | ||
| "type": { | ||
| "option": "optional", | ||
| "type": "string", | ||
| "tag": 2 | ||
| }, | ||
| "__messages": {}, | ||
| "__tags": { | ||
| "1": "id", | ||
| "2": "type" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "items" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "entityId", | ||
| "2": "kindId", | ||
| "3": "bag", | ||
| "4": "equipments" | ||
| } | ||
| } | ||
| }, | ||
| "__tags": { | ||
| "1": "entities", | ||
| "2": "curPlayer", | ||
| "3": "map" | ||
| } | ||
| } | ||
| } |
| { | ||
| "lv":{ | ||
| "message LevelUpMessage": { | ||
| "required string userid" : 1, | ||
| "required int32 delta_xp" : 2, | ||
| "required int32 level" : 3, | ||
| "required int32 level_up" : 4 | ||
| }, | ||
| "repeated LevelUpMessage s" : 1 | ||
| }, | ||
| "ls": { | ||
| "message MS": { | ||
| "repeated Event events" : 1, | ||
| "optional Status status" : 2, | ||
| "message Status": { | ||
| "required int32 status" : 1, | ||
| "required int32 max_player" : 2, | ||
| "required int32 big_blind" : 3, | ||
| "required int32 max_cash" : 4, | ||
| "required int32 buy_in" : 5, | ||
| "required int32 is_sit_and_go" : 6, | ||
| "required int32 dealerindex" : 7, | ||
| "required int32 index" : 8, | ||
| "required int32 turnNumber" : 9, | ||
| "required int32 bet" : 10, | ||
| "required int32 min_bet" : 11, | ||
| "required int32 this_turn_start_index" : 12, | ||
| "repeated int32 table_cards" : 13, | ||
| "required int32 potindex" : 14, | ||
| "repeated Pot pots" : 15, | ||
| "repeated Player userdec" : 16, | ||
| "required int32 animation_time" : 17, | ||
| "required int32 speed" : 18, | ||
| "message Pot": { | ||
| "required int32 cash" : 1, | ||
| "repeated Winner winner" : 2, | ||
| "required int32 userinpot" : 3, | ||
| "message Winner": { | ||
| "optional string userid" : 6, | ||
| "optional int32 hand" : 7, | ||
| "repeated int32 pokers" : 8 | ||
| } | ||
| }, | ||
| "message Player": { | ||
| "optional string userid" : 1, | ||
| "optional string username" : 2, | ||
| "optional int32 isstandup" : 3, | ||
| "optional int32 level" : 4, | ||
| "optional int32 canplay" : 5, | ||
| "optional int32 isplay" : 6, | ||
| "required int32 is_on_table" : 7, | ||
| "optional int32 isallin" : 8, | ||
| "optional int32 card1" : 9, | ||
| "optional int32 card2" : 10, | ||
| "optional int32 turn" : 11, | ||
| "optional int32 bet" : 12, | ||
| "optional int32 money" : 13, | ||
| "optional int32 chair_index" : 14, | ||
| "optional int32 avatar_index" : 15, | ||
| "optional int32 chipcount" : 16, | ||
| "optional int32 action" : 17, | ||
| "optional int32 gift" : 18 | ||
| } | ||
| }, | ||
| "message Event": { | ||
| "optional int32 id" : 1, | ||
| "optional Player1 user" : 2, | ||
| "optional int32 chair_index" : 3, | ||
| "repeated Bet bet" : 4, | ||
| "optional int32 small_bet" : 5, | ||
| "optional string user_id" : 6, | ||
| "optional int32 card1" : 7, | ||
| "optional int32 card2" : 8, | ||
| "optional int32 rank" : 9, | ||
| "optional int32 chips" : 10, | ||
| "repeated string showhand" : 11, | ||
| "optional string friendid" : 12, | ||
| "optional int32 giftid" : 13, | ||
| "message Player1": { | ||
| "required string userid" : 1, | ||
| "required string username" : 2, | ||
| "required int32 isstandup" : 3, | ||
| "required int32 level" : 4, | ||
| "required int32 canplay" : 5, | ||
| "required int32 isplay" : 6, | ||
| "required int32 is_on_table" : 7, | ||
| "required int32 isallin" : 8, | ||
| "required int32 card1" : 9, | ||
| "required int32 card2" : 10, | ||
| "required int32 turn" : 11, | ||
| "required int32 bet" : 12, | ||
| "required int32 money" : 13, | ||
| "required int32 chair_index" : 14, | ||
| "required int32 avatar_index" : 15, | ||
| "required int32 chipcount" : 16, | ||
| "required int32 action" : 17, | ||
| "optional int32 gift" : 18 | ||
| }, | ||
| "message Bet": { | ||
| "required int32 chair_index" : 1, | ||
| "required int32 bet" : 2 | ||
| } | ||
| } | ||
| }, | ||
| "required MS s" : 1 | ||
| } | ||
| } | ||
+26
| var protobuf = require('../lib/protobuf'); | ||
| var util = require('../lib/util'); | ||
| var protos = require('protos.json'); | ||
| protobuf.init({ | ||
| encoderProtos: protos, | ||
| decoderProtos: protos | ||
| }); | ||
| describe('encodeTest', function() { | ||
| for (var route in tc) { | ||
| var msg = tc[route]; | ||
| var buffer = protobuf.encode(route, msg); | ||
| console.log(msg); | ||
| console.log(buffer.length); | ||
| console.log(buffer) | ||
| var decodeMsg = protobuf.decode(route, buffer); | ||
| console.log(decodeMsg); | ||
| util.equal(msg, decodeMsg).should.equal(true); | ||
| } | ||
| }); |
@@ -321,2 +321,3 @@ /* ProtocolBuffer client 0.1.0*/ | ||
| if(typeof(msg[name]) === 'undefined'){ | ||
| console.warn('no property exist for required! name: %j, proto: %j, msg: %j', name, proto, msg); | ||
| return false; | ||
@@ -326,4 +327,6 @@ } | ||
| if(typeof(msg[name]) !== 'undefined'){ | ||
| if(!!protos.__messages[proto.type]){ | ||
| checkMsg(msg[name], protos.__messages[proto.type]); | ||
| var message = protos.__messages[proto.type] || MsgEncoder.protos['message ' + proto.type]; | ||
| if(!!message && !checkMsg(msg[name], message)){ | ||
| console.warn('inner proto error! name: %j, proto: %j, msg: %j', name, proto, msg); | ||
| return false; | ||
| } | ||
@@ -334,5 +337,6 @@ } | ||
| //Check nest message in repeated elements | ||
| if(!!msg[name] && !!protos.__messages[proto.type]){ | ||
| var message = protos.__messages[proto.type] || MsgEncoder.protos['message ' + proto.type]; | ||
| if(!!msg[name] && !!message){ | ||
| for(var i = 0; i < msg[name].length; i++){ | ||
| if(!checkMsg(msg[name][i], protos.__messages[proto.type])){ | ||
| if(!checkMsg(msg[name][i], message)){ | ||
| return false; | ||
@@ -399,8 +403,9 @@ } | ||
| default : | ||
| if(!!protos.__messages[type]){ | ||
| var message = protos.__messages[type] || MsgEncoder.protos['message ' + type]; | ||
| if(!!message){ | ||
| //Use a tmp buffer to build an internal msg | ||
| var tmpBuffer = new ArrayBuffer(codec.byteLength(JSON.stringify(value))); | ||
| var tmpBuffer = new ArrayBuffer(codec.byteLength(JSON.stringify(value))*2); | ||
| var length = 0; | ||
| length = encodeMsg(tmpBuffer, length, protos.__messages[type], value); | ||
| length = encodeMsg(tmpBuffer, length, message, value); | ||
| //Encode length | ||
@@ -452,2 +457,3 @@ offset = writeBytes(buffer, offset, codec.encodeUInt32(length)); | ||
| var value = constant.TYPES[type]||2; | ||
| return codec.encodeUInt32((tag<<3)|value); | ||
@@ -570,6 +576,7 @@ } | ||
| default : | ||
| if(!!protos && !!protos.__messages[type]){ | ||
| var message = protos && (protos.__messages[type] || MsgDecoder.protos['message ' + type]); | ||
| if(!!message){ | ||
| var length = codec.decodeUInt32(getBytes()); | ||
| var msg = {}; | ||
| decodeMsg(msg, protos.__messages[type], offset+length); | ||
| decodeMsg(msg, message, offset+length); | ||
| return msg; | ||
@@ -576,0 +583,0 @@ } |
+3
-2
@@ -109,6 +109,7 @@ var codec = require('./codec'); | ||
| default : | ||
| if(!!protos && !!protos.__messages[type]){ | ||
| var message = protos && (protos.__messages[type] || Decoder.protos['message ' + type]); | ||
| if(message){ | ||
| var length = codec.decodeUInt32(getBytes()); | ||
| var msg = {}; | ||
| decodeMsg(msg, protos.__messages[type], offset+length); | ||
| decodeMsg(msg, message, offset+length); | ||
| return msg; | ||
@@ -115,0 +116,0 @@ } |
+12
-8
@@ -59,3 +59,3 @@ var codec = require('./codec'); | ||
| if(typeof(msg[name]) === 'undefined'){ | ||
| console.warn('no property exist for required! name : %j ,proto : %j, msg : %j, ', name, proto); | ||
| console.warn('no property exist for required! name: %j, proto: %j, msg: %j', name, proto, msg); | ||
| return false; | ||
@@ -65,4 +65,6 @@ } | ||
| if(typeof(msg[name]) !== 'undefined'){ | ||
| if(!!protos.__messages[proto.type]){ | ||
| checkMsg(msg[name], protos.__messages[proto.type]); | ||
| var message = protos.__messages[proto.type] || Encoder.protos['message ' + proto.type]; | ||
| if(!!message && !checkMsg(msg[name], message)){ | ||
| console.warn('inner proto error! name: %j, proto: %j, msg: %j', name, proto, msg); | ||
| return false; | ||
| } | ||
@@ -73,5 +75,6 @@ } | ||
| //Check nest message in repeated elements | ||
| if(!!msg[name] && !!protos.__messages[proto.type]){ | ||
| var message = protos.__messages[proto.type] || Encoder.protos['message ' + proto.type]; | ||
| if(!!msg[name] && !!message){ | ||
| for(var i = 0; i < msg[name].length; i++){ | ||
| if(!checkMsg(msg[name][i], protos.__messages[proto.type])){ | ||
| if(!checkMsg(msg[name][i], message)){ | ||
| return false; | ||
@@ -140,3 +143,4 @@ } | ||
| default : | ||
| if(!!protos.__messages[type]){ | ||
| var message = protos.__messages[type] || Encoder.protos['message ' + type]; | ||
| if(!!message){ | ||
| //Use a tmp buffer to build an internal msg | ||
@@ -146,3 +150,3 @@ var tmpBuffer = new Buffer(Buffer.byteLength(JSON.stringify(value))*2); | ||
| length = encodeMsg(tmpBuffer, length, protos.__messages[type], value); | ||
| length = encodeMsg(tmpBuffer, length, message, value); | ||
| //Encode length | ||
@@ -197,2 +201,2 @@ offset = writeBytes(buffer, offset, codec.encodeUInt32(length)); | ||
| return codec.encodeUInt32((tag<<3)|value); | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "pomelo-protobuf", | ||
| "version": "0.3.5", | ||
| "version": "0.4.0", | ||
| "main": "./lib/protobuf", | ||
@@ -5,0 +5,0 @@ "dependencies": {}, |
+36
-0
@@ -41,2 +41,38 @@ #Pomelo-protobuf | ||
| ###RootMessage support | ||
| you can write rootMessage in protos for global usage | ||
| ``` | ||
| { | ||
| "message Path": { | ||
| "required double x" : 1, | ||
| "required double y" : 2 | ||
| }, | ||
| "message Equipment" : { | ||
| "required uInt32 entityId" : 1, | ||
| "required uInt32 kindId" : 2 | ||
| }, | ||
| "onMove" : { | ||
| "required uInt32 entityId" : 1, | ||
| "repeated Path path" : 2, | ||
| "required float speed" : 3 | ||
| }, | ||
| "area.playerHandler.enterScene" : { | ||
| "message Player" : { | ||
| "message Bag" : { | ||
| "message Item" : { | ||
| "required uInt32 id" : 1, | ||
| "optional string type" : 2 | ||
| }, | ||
| "repeated Item items" : 1 | ||
| }, | ||
| "required uInt32 entityId" : 1, | ||
| "required uInt32 kindId" : 2, | ||
| "required Bag bag" : 3, | ||
| "repeated Equipment equipments" : 4 | ||
| }, | ||
| "optional Player curPlayer" : 2 | ||
| } | ||
| } | ||
| ``` | ||
| ###Server side and Client side | ||
@@ -43,0 +79,0 @@ Pomelo-protobuf has server code and client code for js. |
| var protobuf = require('../../lib/client/protobuf'); | ||
| var protobufServer = require('../../lib/protobuf'); | ||
| var encoder = protobuf.encoder; | ||
@@ -15,2 +16,3 @@ var decoder = protobuf.decoder; | ||
| protobuf.init({encoderProtos:protos, decoderProtos:protos}); | ||
| protobufServer.init({encoderProtos:protos, decoderProtos:protos}); | ||
@@ -21,2 +23,3 @@ describe('protobufTest', function(){ | ||
| var buffer = protobuf.encode(route, msg); | ||
| var decodeMsg = protobuf.decode(route, buffer); | ||
@@ -27,2 +30,12 @@ | ||
| }); | ||
| }); | ||
| }); | ||
| function toBuffer(arr){ | ||
| var buffer = new Buffer(arr.length); | ||
| for(var i = 0; i < arr.length; i++){ | ||
| buffer.writeUInt8(arr[i], i); | ||
| } | ||
| return buffer; | ||
| } |
@@ -16,3 +16,3 @@ var protobuf = require('../lib/protobuf'); | ||
| console.log(msg); | ||
| console.log(msg); | ||
| console.log(buffer.length); | ||
@@ -19,0 +19,0 @@ console.log(buffer) |
| var protobuf = require('../lib/protobuf'); | ||
| var fs = require('fs'); | ||
| var protos = protobuf.parse(require('./example.json')); | ||
| var protoFile = "./rootMsg.json"; | ||
| var protoTarget = "./rootProtos.json"; | ||
| var msgFile = "./rootMsgTC"; | ||
| var msgTarget = "./rootMsg.json"; | ||
| var protos = protobuf.parse(require(protoFile)); | ||
| console.log(protos); | ||
| fs.writeFile('./protos.json', JSON.stringify(protos, null ,2)); | ||
| fs.writeFile(protoTarget, JSON.stringify(protos, null ,2)); | ||
| fs.writeFile('./msg.json', JSON.stringify(require('./testMsg'), null ,2)); | ||
| fs.writeFile(msgTarget, JSON.stringify(require(msgFile), null ,2)); | ||
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
115660
49.63%37
48%4387
53.5%153
30.77%5
150%1
Infinity%