Best JavaScript code snippet using unexpected
socket.js
Source:socket.js
1import io from '@/js_sdk/hyoga-uni-socket_io/uni-socket.io.js';2// import live from './liveSocket.js'3// var config = {4// dev: "http://chat-room-dev.leihuozb.com",5// ol: "https://chat-room.leihuozb.com",6// local: 'http://154.204.42.66:19977',7// shut: "ç¦è¨",8// kick: "踢åº",9// black: "æé»",10// method: "get",11// }1213var socket;14var room = {15 /**16 * åå§åç¯å¢17 */18 initEnv: function (data) { 19 socket = io(data, {20 query: {},21 transports: [ 'websocket' ],22 timeout: 5000,23 });24 },25 26 /**27 * è¿æ¥28 */29 connect: function (data) {30 socket.on('connect', () => {31 32 let connData = {33 nickname: data.nickname,34 uid: data.uid,35 token: data.token,36 roomnum: data.roomnum,37 equipment: data.equipment,38 stream: data.stream39 };40 41 socket.emit('conn', connData);42 });43 },44 45 /**46 * çå¬47 */48 listeners: function () {49 50 socket.on('disconnect', (msg) => {51 console.log('disconnect', msg);52 });53 socket.on('broadcast', (msg) => {54 console.log('broadcast', msg);55 });56 socket.on('heartbeat', (msg) => {57 console.log('heartbeat', msg);58 socket.emit("heartbeat", "heartbeat");59 });60 socket.on('error', (msg) => {61 console.log('error', msg);62 });63 socket.on('conn', (msg) => {64 console.log('conn', msg);65 room.action.zombie();66 });67 68 socket.on('broadcastingListen', (data) => {69 console.log('broadcastingListen', data);70 let arrayData = JSON.stringify(data);71 72 let subArrayData = arrayData[0];73 if (subArrayData[0] == "stopplay") {74 // [weakself.socketDelegate roomCloseByAdmin];75 return;76 }77 78 for (let path in subArrayData) {79 let jsonDict = path;80 let tmpArray = jsonDict.msg;81 let msg = tmpArray[0];82 let retcode = jsonDict.retcode;83 84 if (retcode == 409002) {85 uni.showToast({86 title:"ä½ å·²è¢«ç¦è¨",87 icon:'none',88 duration:200089 })90 return;91 }92 93 let method = msg._method_;94 room.getMessage(method, msg);95 }96 });97 },98 getMessage: function (method, msg) {99 100 //åµå°¸ç²101 if (method == "requestFans") {102 let ct = msg.ct;103 let data = ct.data;104 if (data.code == 0) {105 let info = data.info;106 let tmpArray = info.list;107 let list = tmpArray[0];108 // [self.socketDelegate addZombieByArray:list];109 }110 }111 //ä¼è¯æ¶æ¯112 if (method == "SendMsg") {113 let msgtype = msg.msgtype;114 if (msgtype == "2") {115 let ct = '';116 //ç¹äº®117 if (msg.heart != nil) {118 let lightColor = msg.heart;119 let light = "light";120 let titleColor = light+lightColor;121 ct = msg.ct;122 let uname = msg.uname;123 let levell = msg.level;124 let uid = msg.uid;125 let vip_type = msg.vip_type;126 let liangname = msg.liangname;127 let usertype = msg.usertype;128 let guardType = msg.guard_type;129 130 let chat = {131 userName: uname,132 contentChat: ct,133 levelI: level,134 id: uid,135 titleColor: titleColor,136 vip_type: vip_type,137 liangname: liangname,138 usertype: usertype,139 guard_type: guardType140 }141 // [self.socketDelegate light:chat];142 }143 else{144 let titleColor = "0";145 ct = msg.ct;146 let uname = msg.uname;147 let level = msg.level;148 let uid = msg.uid;149 let vip_type = msg.vip_type;150 let liangname = msg.liangname;151 let usertype = msg.usertype;152 let isAnchor = msg.isAnchor;153 let guardType = msg.guard_type;154 155 let chat = {156 userName: uname,157 contentChat: ct,158 levelI: level,159 id: uid,160 titleColor: titleColor,161 vip_type: vip_type,162 liangname: liangname,163 usertype: usertype,164 isAnchor: isAnchor,165 guard_type: guardType166 }167 // [self.socketDelegate messageListen:chat];168 }169 }170 //ç¨æ·ç¦»å¼è¿å
¥171 else if (msgtype == "0") {172 let action = msg.action;173 //ç¨æ·ç¦»å¼174 if (action == "1") {175 //NSLog(@"ç¨æ·ç¦»å¼ï¼%@",msg);176 // [self.socketDelegate UserLeave:msg];177 }178 //ç¨æ·è¿å
¥179 if (action == "0") {180 // [self.socketDelegate UserAccess:msg];181 }182 }183 //ç´æå
³é184 if (msgtype == "1") {185 let action = msg.action;186 if (action == "18") {187 // NSLog(@"ç´æå
³é");188 // [self.socketDelegate LiveOff];189 }190 }191 if (msgtype == "26") {192 193 }194 //å红å
195 // if ([msgtype isEqual:@"255"]) {196 // NSString *action = [msg valueForKey:@"action"];197 // //198 // if ([action isEqual:@"0"]) {199 // [self.socketDelegate showRedbag:msg];200 // }201 // }202 203 }204 //å¢å æ 票205 // else if ([method isEqual:@"updateVotes"]){206 // NSString *msgtype = [msg valueForKey:@"msgtype"];207 // if ([msgtype isEqual:@"26"]) {208 // //éå¶è¿æ¿é´çæ¶åèªå·±ä¸å¢å 209 // NSString *uid = minstr([msg valueForKey:@"uid"]);210 // if (![uid isEqual:[HConfig getOwnID]]) {211 // [self.socketDelegate addvotesdelegate:[msg valueForKey:@"votes"]];212 // }213 // }214 // }215 //æ¿é´ç±»ååæ¢216 else if (method == "changeLive") {217 // [self.socketDelegate changeLive:[NSString stringWithFormat:@"%@",[msg valueForKey:@"type_val"]]];218 }219 //ç¹äº®220 else if (method == "light") {221 let msgtype = msg.msgtype;222 if (msgtype == "0") {223 let action = msg.action ;224 //ç¹äº®225 if (action == "2") {226 // [self.socketDelegate sendLight];227 }228 }229 }230 //设置管çå231 else if (method == "SystemNot" || method == "ShutUpUser") {232 let msgtype = msg.msgtype;233 let action = msg.action;234 let touid = msg.touid;235 if(msgtype == "4" && action == "13") {236 //设置åæ¶ç®¡çå237 // if ([touid isEqual:[HConfig getOwnID]]) {238 // [self alertShowMsg:minstr([msg valueForKey:@"ct"]) andTitle:YZMsg(@"æ示")];239 // }240 }241 else if (msgtype == "4" && action == "1") {242 //ç¦è¨243 // if ([touid isEqual:[HConfig getOwnID]]) {244 // [self alertShowMsg:minstr([msg valueForKey:@"ct"]) andTitle:YZMsg(@"æ示")];245 // }246 }247 // [self.socketDelegate setSystemNot:msg];248 } 249 else if (method == "setAdmin") {250 let ct = msg.ct;251 if (ct) {252 // [self.socketDelegate setAdmin:msg];253 }254 }255 // else if ([method isEqual:@"shopGoodsLiveFloat"]){256 // [self.socketDelegate showLiveGooodTips:msg];257 // }258 // else if ([method isEqual:@"Sendplatgift"]){259 // //å
¨ç«ç¤¼ç©260 // [self.socketDelegate sendAllStationsGift:msg];261 // }262 //é礼ç©263 // else if ([method isEqual:@"SendGift"]) {264 // // NSString *titleColor = @"2";265 // if ([minstr([msg valueForKey:@"ifpk"]) isEqual:@"1"]) {266 // [self.socketDelegate changePkProgressViewValue:msg];267 // if (![minstr([msg valueForKey:@"roomnum"]) isEqual:minstr([_playDoc valueForKey:@"uid"])]) {268 // return;269 // }270 // }271 272 // NSString *haohualiwu = [NSString stringWithFormat:@"%@",[msg valueForKey:@"evensend"]];273 // NSDictionary *ct = [msg valueForKey:@"ct"];274 275 // NSDictionary *GiftInfo = @{@"uid":[msg valueForKey:@"uid"],276 // @"nicename":[msg valueForKey:@"uname"],277 // @"giftname":[ct valueForKey:@"giftname"],278 // @"gifticon":[ct valueForKey:@"gifticon"],279 // @"giftcount":[ct valueForKey:@"giftcount"],280 // @"giftid":[ct valueForKey:@"giftid"],281 // @"level":[msg valueForKey:@"level"],282 // @"avatar":[msg valueForKey:@"uhead"],283 // @"type":[ct valueForKey:@"type"],284 // @"swf":minstr([ct valueForKey:@"swf"]),285 // @"swftime":minstr([ct valueForKey:@"swftime"]),286 // @"swftype":minstr([ct valueForKey:@"swftype"]),287 // @"isluck":minstr([ct valueForKey:@"isluck"]),288 // @"lucktimes":minstr([ct valueForKey:@"lucktimes"]),289 // @"mark":minstr([ct valueForKey:@"mark"]),290 // @"livename":minstr([msg valueForKey:@"livename"]),291 // @"isplatgift":minstr([ct valueForKey:@"isplatgift"]),292 // @"paintedPath":[msg valueForKey:@"paintedPath"],293 // @"paintedHeight":minstr([msg valueForKey:@"paintedHeight"]),294 // @"paintedWidth":minstr([msg valueForKey:@"paintedWidth"])295 296 // };297 // [self.socketDelegate sendGift:nil andLiansong:haohualiwu andTotalCoin:minstr([ct valueForKey:@"votestotal"]) andGiftInfo:GiftInfo andCt:ct];298 // } 299 // else if ([method isEqual:@"luckWin"]) {//幸è¿ç¤¼ç©300 // [self.socketDelegate showAllLuckygift:msg];301 // NSLog(@"幸è¿ç¤¼ç©%@",msg);302 // }303 // else if ([method isEqual:@"jackpotWin"]) {//å¥æ± ä¸å¥304 // [self.socketDelegate WinningPrize:msg];305 // NSLog(@"å¥æ± ä¸å¥%@",msg);306 // }307 // else if ([method isEqual:@"jackpotUp"]) {//å¥æ± å级308 // [self.socketDelegate JackpotLevelUp:msg];309 // NSLog(@"å¥æ± å级%@",msg);310 // }311 else if (method == "SendBarrage") {//å¼¹å¹312 // [self.socketDelegate SendBarrage:msg];313 // NSLog(@"å¼¹å¹æ¥åæå%@",msg);314 }315 else if (method == "StartEndLive") {//ç»æç´æ316 // [self.socketDelegate StartEndLive];317 }318 else if (method == "disconnect") {//æå¼é¾æ¥319 // [self.socketDelegate UserDisconnect:msg];320 }321 // else if ([method isEqual:@"goodsLiveShow"]){//ç´æé´ååçªå£322 // [self.socketDelegate showLiveGoodsWithDic:msg];323 // }324 else if (method == "KickUser") {//踢人æ¶æ¯325 let unamessss = msg.touid;326 // if([unamessss isEqual:[HConfig getOwnID]] ){327 // [self.socketDelegate kickOK];328 // }329 let titleColor = "firstlogin";330 let ct = msg.ct;331 let uname = "ç´æé´æ¶æ¯";332 let levell = " ";333 let ID = " ";334 let icon = " ";335 let vip_type = "0";336 let liangname = "0";337 338 let chat = {339 userName: uname,340 contentChat: ct,341 levelI: levell,342 id: ID,343 titleColor: titleColor,344 avatar: icon,345 vip_type: vip_type,346 liangname: liangname347 }348 // [self.socketDelegate KickUser:chat];349 }350 /*351 1 æ人åéè¿éº¦è¯·æ±352 2 主ææ¥åè¿éº¦353 3 主ææç»è¿éº¦354 4 ç¨æ·æ¨æµï¼åéèªå·±çææµå°å355 5 ç¨æ·æå¼è¿éº¦356 6 主ææå¼è¿éº¦357 7 主ææ£å¿ç¢358 8 主ææ ååº359 */360 // else if ([method isEqual:@"ConnectVideo"]){361 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];362 // if ([action isEqual:@"1"]) {363 // return;364 // }365 // if ([action isEqual:@"4"]) {366 // NSString *uid = [NSString stringWithFormat:@"%@",[msg valueForKey:@"uid"]];367 // if (![uid isEqual:[HConfig getOwnID]]) {368 // //ä¸æ¯è¿éº¦ç¨æ·çå
¶ä»ç¨æ·ææ¾è¿éº¦ç¨æ·çæµ369 // [self.socketDelegate playLinkUserUrl:minstr([msg valueForKey:@"playurl"]) andUid:minstr([msg valueForKey:@"uid"])];370 // }371 // }372 // if ([action isEqual:@"5"]){373 // [self.socketDelegate hostout];374 // if (![minstr([msg valueForKey:@"uid"]) isEqual:[HConfig getOwnID]]) {375 // [MBProgressHUD showError:[NSString stringWithFormat:@"%@%@",minstr([msg valueForKey:@"uname"]),YZMsg(@"å·²ä¸éº¦")]];376 // }377 // }378 // if ([action isEqual:@"6"]) {379 // [self.socketDelegate hostout];380 // if ([minstr([msg valueForKey:@"touid"]) isEqual:[HConfig getOwnID]]) {381 // [MBProgressHUD showError:YZMsg(@"主æå·²æä½ ä¸éº¦")];382 // }else{383 // [MBProgressHUD showError:[NSString stringWithFormat:@"%@%@",minstr([msg valueForKey:@"uname"]),YZMsg(@"å·²ä¸éº¦")]];384 // }385 // }386 // NSString *touid = [NSString stringWithFormat:@"%@",[msg valueForKey:@"touid"]];387 // if ([touid isEqual:[HConfig getOwnID]]) {388 // if ([action isEqual:@"2"]) {389 // //åæè¿éº¦390 // [self.socketDelegate startConnectvideo];391 // }392 // else if ([action isEqual:@"3"]){393 // //æç»è¿éº¦394 // [MBProgressHUD hideHUD];395 // [MBProgressHUD showError:YZMsg(@"主ææç»äºæ¨çè¿éº¦è¯·æ±")];396 // [self.socketDelegate enabledlianmaibtn];397 // }398 399 // //主ææ£å¿ç¢400 // if ([action isEqual:@"7"]) {401 // [MBProgressHUD hideHUD];402 // [MBProgressHUD showError:YZMsg(@"主ææ£å¿ç¢")];403 // [self.socketDelegate enabledlianmaibtn];404 // }405 // //主ææªååº406 // if ([action isEqual:@"8"]) {407 // [MBProgressHUD hideHUD];408 // [MBProgressHUD showError:YZMsg(@"å½å主æææ¶æ æ³æ¥é")];409 // [self.socketDelegate enabledlianmaibtn];410 // }411 // //主ææªååº412 // if ([action isEqual:@"10"]) {413 // [MBProgressHUD hideHUD];414 // [MBProgressHUD showError:YZMsg(@"主ææªå¼å¯è¿éº¦åè½å¦")];415 // [self.socketDelegate enabledlianmaibtn];416 // }417 418 // }419 420 // }421 // else if ([method isEqual:@"BuyGuard"]){//è´ä¹°å®æ¤422 // [self.socketDelegate updateGuardMsg:msg];423 // NSDictionary *dic = @{@"ct":[NSString stringWithFormat:@"%@ %@",minstr([msg valueForKey:@"uname"]),YZMsg(@"å®æ¤äºä¸»æ")]};424 // [self.socketDelegate setSystemNot:dic];425 // }426 // else if ([method isEqual:@"SendRed"]) {//å红å
427 // NSString *action = [msg valueForKey:@"action"];428 // //429 // if ([action isEqual:@"0"]) {430 // [self.socketDelegate showRedbag:msg];431 // }432 // } 433 else if (method == "LiveConnect"){434 //1ï¼åèµ·è¿éº¦ï¼2ï¼æ¥åè¿éº¦ï¼3:æç»è¿éº¦ï¼4ï¼è¿éº¦æåéç¥ï¼5.æå¨æå¼è¿éº¦;7:对æ¹æ£å¿ç¢ 8:对æ¹æ ååº435 let action = msg.action;436 switch (action) {437 case 4:438 // [self.socketDelegate anchor_agreeLink:msg];439 break;440 case 5:441 // [self.socketDelegate anchor_stopLink:msg];442 break;443 default:444 break;445 }446 }447 // else if ([method isEqual:@"LivePK"]){448 // //1ï¼åèµ·PKï¼2ï¼æ¥åPKï¼3:æç»PKï¼4ï¼PKæåéç¥ï¼5.;7:对æ¹æ£å¿ç¢ 8:对æ¹æ ååº 9:PKç»æ449 // int action = [minstr([msg valueForKey:@"action"]) intValue];450 // switch (action) {451 // case 4:452 // [self.socketDelegate showPKView:nil];453 // break;454 // case 9:455 // [self.socketDelegate showPKResult:msg];456 // break;457 458 // default:459 // break;460 // }461 // }462 //ç¸éè±//æ¶å°ä¸»æ广æåå¤å¼å§æ¸¸æ463 ////æ¶å°ä¸»æ广æåå¤å¼å§æ¸¸æ464 // else if ([method isEqual:@"startGame"] || [method isEqual:@"startLodumaniGame"] || [method isEqual:@"startCattleGame"] ){465 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];466 // NSString *msgtype = [NSString stringWithFormat:@"%@",[msg valueForKey:@"msgtype"]];467 // if ([action isEqual:@"1"]) {468 // //åºç°æ¸¸æçé¢469 // [self.socketDelegate prepGameandMethod:method andMsgtype:msgtype];470 // }471 // else if ([action isEqual:@"2"]){472 // if ([method isEqual:@"startCattleGame"]) {473 // NSDictionary *bankdic = [msg valueForKey:@"bankerlist"];474 // [self.socketDelegate changeBank:bankdic];475 // }476 // //å¼å§åç477 // [self.socketDelegate takePoker:[msg valueForKey:@"gameid"] Method:method andMsgtype:msgtype];478 479 // }480 // else if ([action isEqual:@"3"]){481 // //主æå
³é游æ482 // [self.socketDelegate stopGame];483 // }484 // else if ([action isEqual:@"4"]){485 // //游æå¼å§ åæ°è®¡æ¶486 // NSString *time = [NSString stringWithFormat:@"%@",[msg valueForKey:@"time"]];//游ææ¶é´487 // [self.socketDelegate startGame:time andGameID:[msg valueForKey:@"gameid"]];488 // }489 // else if ([action isEqual:@"5"]){490 // //ç¨æ·æ注491 // NSString *money = [NSString stringWithFormat:@"%@",[msg valueForKey:@"money"]];492 // NSString *type = [NSString stringWithFormat:@"%@",[msg valueForKey:@"type"]];493 // [self.socketDelegate getCoin:type andMoney:money];494 // }else if ([action isEqual:@"6"]){495 // //å¼å¥496 // NSArray *ct = [msg valueForKey:@"ct"];497 // [self.socketDelegate getResult:ct];498 // }499 // }500 // else if ([method isEqual:@"startRotationGame"]){501 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];502 // if ([action isEqual:@"1"]) {503 // //åºç°æ¸¸æçé¢504 // [self.socketDelegate prepRotationGame];505 // }506 // else if ([action isEqual:@"2"]){507 508 509 // }510 // else if ([action isEqual:@"3"]){511 // //主æå
³é游æ512 // [self.socketDelegate stopRotationGame];513 514 // }515 // else if ([action isEqual:@"4"]){516 // //游æå¼å§ åæ°è®¡æ¶517 // NSString *time = [NSString stringWithFormat:@"%@",[msg valueForKey:@"time"]];//游ææ¶é´518 // [self.socketDelegate startRotationGame:time andGameID:[msg valueForKey:@"gameid"]];519 // }520 // else if ([action isEqual:@"5"]){521 // //ç¨æ·æ注522 // NSString *money = [NSString stringWithFormat:@"%@",[msg valueForKey:@"money"]];523 // NSString *type = [NSString stringWithFormat:@"%@",[msg valueForKey:@"type"]];524 // [self.socketDelegate getRotationCoin:type andMoney:money];525 // }else if ([action isEqual:@"6"]){526 // //å¼å¥527 // NSArray *ct = [msg valueForKey:@"ct"];528 // [self.socketDelegate getRotationResult:ct];529 // }530 // }531 //äºå
«è´532 // else if ([method isEqual:@"startShellGame"]){533 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];534 // NSString *msgtype = [NSString stringWithFormat:@"%@",[msg valueForKey:@"msgtype"]];535 // if ([action isEqual:@"1"]) {536 // //åºç°æ¸¸æçé¢537 // [self.socketDelegate shellprepGameandMethod:method andMsgtype:msgtype];538 // }539 // else if ([action isEqual:@"2"]){540 // //å¼å§åç541 // [self.socketDelegate shelltakePoker:[msg valueForKey:@"gameid"] Method:method andMsgtype:msgtype];542 // }543 // else if ([action isEqual:@"3"]){544 // //主æå
³é游æ545 // [self.socketDelegate shellstopGame];546 // }547 // else if ([action isEqual:@"4"]){548 // //游æå¼å§ åæ°è®¡æ¶549 // NSString *time = [NSString stringWithFormat:@"%@",[msg valueForKey:@"time"]];//游ææ¶é´550 // [self.socketDelegate shellstartGame:time andGameID:[msg valueForKey:@"gameid"]];551 // }552 // else if ([action isEqual:@"5"]){553 // //ç¨æ·æ注554 // NSString *money = [NSString stringWithFormat:@"%@",[msg valueForKey:@"money"]];555 // NSString *type = [NSString stringWithFormat:@"%@",[msg valueForKey:@"type"]];556 // [self.socketDelegate shellgetCoin:type andMoney:money];557 // }else if ([action isEqual:@"6"]){558 // //å¼å¥559 // NSArray *ct = [msg valueForKey:@"ct"];560 // [self.socketDelegate shellgetResult:ct];561 // }562 // }563 // else if ([method isEqual:@"shangzhuang"]){564 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];565 // //æ人ä¸åº566 // if ([action isEqual:@"1"]) {567 // NSDictionary *subdic = @{568 // @"uid":[msg valueForKey:@"uid"],569 // @"uhead":[msg valueForKey:@"uhead"],570 // @"uname":[msg valueForKey:@"uname"],571 // @"coin":[msg valueForKey:@"coin"]572 // };573 // [self.socketDelegate getzhuangjianewmessagedelegatem:subdic];574 // }575 // }576 577 },578 579 /**580 * å
³éè¿æ¥581 */582 close: function (data) {583 socket.close();584 },585586 /**587 * çå¬588 */589 listeners: function () {590 591 socket.on('broadcastingListen', (msg) => {592 console.log('broadcastingListen', msg);593 });594 socket.on('disconnect', (msg) => {595 console.log('disconnect', msg);596 });597 socket.on('broadcast', (msg) => {598 console.log('broadcast', msg);599 });600 socket.on('heartbeat', (msg) => {601 console.log('heartbeat', msg);602 socket.emit("heartbeat", "heartbeat");603 });604 socket.on('error', (msg) => {605 console.log('error', msg);606 });607 socket.on('conn', (msg) => {608 console.log('conn', msg);609 room.action.zombie();610 });611 },612 613 action: {614 /**615 *åµå°¸ç²616 */617 zombie: function () {618 let connData = {619 msg: [620 {621 _method_: "requestFans",622 timestamp:"",623 msgtype: "0",624 }625 ],626 retcode: "000000",627 retmsg: "OK"628 };629 console.log(connData);630 socket.emit('broadcast', connData);631 },632 633 /**634 *å¢å æ 票635 */636 addvotes: function (data) {637 let connData = {638 msg: [639 {640 _method_: "updateVotes",641 action: "1",642 votes: data.votes,643 msgtype: "26",644 uid: data.uid,645 isfirst: data.isfirst646 }647 ],648 retcode: "000000",649 retmsg: "OK"650 }651 console.log(connData);652 socket.emit('broadcast', connData);653 },654 655 /**656 *å
³æ³¨ä¸»æ657 */658 attentionLive: function (data) {659 let connData = {660 msg: [661 {662 _method_: "SystemNot",663 action: "13",664 ct: data.ct,665 msgtype: "4",666 timestamp: "",667 tougood: "",668 touid: "0",669 city:"",670 touname: "",671 ugood: "",672 uid: data.uid,673 uname: data.uname,674 equipment: "app",675 roomnum: data.roomnum,676 usign:"",677 uhead:"",678 level:data.level,679 sex:""680 }681 ],682 retcode: "000000",683 retmsg: "OK"684 }685 console.log(connData);686 socket.emit('broadcast', connData);687 },688 689 /**690 *æ¿é´å
³é691 */692 stopRoom: function (data) {693 let connData = {694 msg: [695 {696 _method_: "stopLive",697 action: "19",698 ct:"",699 msgtype: "1",700 timestamp: "",701 tougood: "",702 touid: "0",703 touname: "",704 ugood: data.ugood,705 uid: data.uid,706 uname: data.uname,707 equipment: "app",708 roomnum: data.roomnum,709 usign:"",710 uhead: data.uhead,711 level: data.level,712 city:"",713 sex:""714 }715 ],716 retcode: "000000",717 retmsg: "OK"718 }719 console.log(connData);720 socket.emit('broadcast', connData);721 },722 723 /**724 *åéæ¶æ¯725 */726 sendmessage: function (data) {727 let connData = {728 msg: [729 {730 _method_:"SendMsg",731 action:"0",732 ct: data.ct,733 msgtype:"2",734 timestamp:"",735 tougood:"",736 touid:"0",737 city:"",738 touname:"",739 ugood:"",740 uid: data.uid,741 uname:data.uname,742 equipment:"app",743 roomnum:data.roomnum,744 usign:"",745 uhead:"",746 level:data.level,747 sex:"",748 vip_type:data.vipType,749 liangname:data.liangname,750 isAnchor:"0",751 usertype:data.usertype,752 guard_type:data.guardtype753 }754 ],755 retcode:"000000",756 retmsg:"OK"757 }758 console.log(connData);759 socket.emit('broadcast', connData);760 },761 762 /**763 *é礼ç©764 */765 sendGift: function (data) {766 let connData = {767 msg: [768 {769 _method_: "SendGift",770 action: "0",771 ct:info ,772 msgtype: "1",773 uid: data.uid,774 uname: data.uname,775 equipment: "app",776 roomnum: data.roomnum,777 level:data.level,778 evensend:data.evensend,779 uhead:data.uhead,780 vip_type:data.viptype,781 liangname:data.liangame,782 livename:data.livename,783 paintedPath:data.paintedPath,784 paintedHeight:data.paintedHeight,785 paintedWidth:data.paintedWidth786 }787 ],788 retcode: "000000",789 retmsg: "OK"790 }791 console.log(connData);792 socket.emit('broadcast', connData);793 },794 795 /**796 *ç¦è¨797 */798 shutUp: function (data) {799 let connData = {800 msg: [801 {802 _method_:"ShutUpUser",803 action:"1",804 ct:data.ct,805 uid:data.uid,806 touid:data.touid,807 showid:data.showid,808 uname:"",809 msgtype:"4",810 timestamp:"",811 tougood:"",812 touname:"",813 ugood:""814 }815 ],816 retcode:"000000",817 retmsg:"OK"818 }819 console.log(connData);820 socket.emit('broadcast', connData);821 },822 823 /**824 *踢人825 */826 kickUser: function (data) {827 let connData = {828 msg: [829 {830 _method_:"KickUser",831 action:"2",832 ct:data.ct,833 uid:data.uid,834 touid:data.touid,835 showid:data.showid,836 uname:"",837 msgtype:"4",838 timestamp:"",839 tougood:"",840 touname:"",841 ugood:""842 },843 ],844 retcode:"000000",845 retmsg:"OK"846 }847 console.log(connData);848 socket.emit('broadcast', connData);849 },850 851 /**852 *å¼¹å¹853 */854 sendBarrage: function (data) {855 let connData = {856 msg: [857 {858 _method_: "SendBarrage",859 action: "7",860 ct:ct ,861 msgtype: "1",862 ugood: data.ugood,863 uid: data.uid,864 uname: data.uname,865 equipment: "app",866 roomnum: data.roomnum,867 level:data.level,868 uhead:data.uhead,869 vip_type:data.viptype,870 liangname:data.liangname871 }872 ],873 retcode: "000000",874 retmsg: "OK"875 }876 console.log(connData);877 socket.emit('broadcast', connData);878 },879 880 /**881 *ç¹äº®882 */883 starlight: function (data) {884 let connData = {885 msg: [886 {887 _method_: "SendMsg",888 action: "0",889 ct: "æç¹äº®äº",890 msgtype: "2",891 uid: data.uid,892 uname: data.nicename,893 equipment: "app",894 roomnum: data.roomnum,895 level:data.level,896 heart: data.heart,897 vip_type: data.viptype,898 liangname: data.liangname,899 usertype: data.usertype,900 guard_type: data.guardType901 }902 ],903 retcode: "000000",904 retmsg: "OK"905 }906 console.log(connData);907 socket.emit('broadcast', connData);908 },909 910 /**911 *è¿éº¦socket912 */913 sendLianMai: function (data) {914 let connData = {915 msg: [916 {917 _method_:"ConnectVideo",918 action: "5",919 msgtype: "10",920 uid:data.uid,921 uname:data.uname,922 }923 ],924 retcode: "000000",925 retmsg: "OK"926 }927 console.log(connData);928 socket.emit('broadcast', connData);929 },930 931 /**932 *è¿éº¦933 */934 sendSmall: function (data) {935 let connData = {936 msg: [937 {938 _method_: "updateVotes",939 action:"1",940 votes:data.votes,941 msgtype: "26",942 uid:data.uid,943 isfirst:data.isfirst944 }945 ],946 retcode: "000000",947 retmsg: "OK"948 }949 console.log(connData);950 socket.emit('broadcast', connData);951 },952 953 /**954 *close connect955 */956 closeConnect: function (data) {957 let connData = {958 msg: [959 {960 _method_: "ConnectVideo",961 action:"5",962 msgtype: "10",963 uid:data.uid,964 uname:data.uname965 }966 ],967 retcode: "000000",968 retmsg: "OK"969 }970 console.log(connData);971 socket.emit('broadcast', connData);972 },973 974 /**975 *videoToHost976 */977 videoToHost: function (data) {978 let connData = {979 msg: [980 {981 _method_: "ConnectVideo",982 action:"1",983 msgtype: "10",984 uid:data.uid,985 uname:data.uname,986 uhead:data.uhead,987 level:data.level,988 sex:data.sex989 }990 ],991 retcode: "000000",992 retmsg: "OK"993 }994 console.log(connData);995 socket.emit('broadcast', connData);996 },997 998 /**999 *buyGuard1000 */1001 buyGuard: function (data) {1002 let connData = {1003 msg: [1004 {1005 _method_: "BuyGuard",1006 action:"0",1007 msgtype: "0",1008 ct:"å®æ¤äºä¸»æ",1009 uid:data.uid,1010 uname:data.uname,1011 uhead:data.uhead,1012 votestotal:data.votestotal,1013 guard_nums:data.guardnums1014 }1015 ],1016 retcode: "000000",1017 retmsg: "OK"1018 }1019 console.log(connData);1020 socket.emit('broadcast', connData);1021 },1022 1023 /**1024 *fahongbaola1025 */1026 fahongbaola: function (data) {1027 let connData = {1028 msg: [1029 {1030 _method_: "SendRed",1031 action: "0",1032 ct:"å¨ç´æé´å红å
å¦ï¼å¿«å»æ¢å¦",1033 msgtype: "0",1034 timestamp: "",1035 touid: "0",1036 ugood: data.ugood,1037 uid: data.uid,1038 uname: data.uname,1039 equipment: "app",1040 uhead:data.uhead,1041 level:data.level,1042 vip_type:data.viptype,1043 liangname:data.liangname,1044 isAnchor:"0"1045 }1046 ],1047 retcode: "000000",1048 retmsg: "OK"1049 }1050 console.log(connData);1051 socket.emit('broadcast', connData);1052 },1053 1054 /**1055 *stakePoke1056 */1057 stakePoke: function (data) {1058 let connData = {1059 msg: [1060 {1061 _method_: data.method,1062 action: "5",1063 msgtype:data.msgtype,1064 type:data.type,1065 money:data.money,1066 uid:data.uid1067 }1068 ],1069 retcode: "000000",1070 retmsg: "OK"1071 }1072 console.log(connData);1073 socket.emit('broadcast', connData);1074 },1075 1076 /**1077 *stakeRotationPoke1078 */1079 stakeRotationPoke: function (data) {1080 let connData = {1081 msg: [1082 {1083 _method_: "startRotationGame",1084 action: "5",1085 msgtype:"16",1086 type:data.type,1087 money:data.money,1088 uid:data.uid1089 }1090 ],1091 retcode: "000000",1092 retmsg: "OK"1093 }1094 console.log(connData);1095 socket.emit('broadcast', connData);1096 },1097 1098 /**1099 *getzhuangjianewm1100 */1101 getzhuangjianewm: function (data) {1102 let connData = {1103 msg: [1104 {1105 _method_:"shangzhuang",1106 action:"1",1107 msgtype:"25",1108 uid:data.uid,1109 uhead:data.uhead,1110 uname:data.uname,1111 coin:data.coin1112 }1113 ],1114 retcode: "000000",1115 retmsg: "OK"1116 }1117 console.log(connData);1118 socket.emit('broadcast', connData);1119 },1120 1121 // /**1122 // *1123 // * è¶
管弹å¹å·æ°1124 // *1125 // * @return mixed $data default string,1126 // * @example1127 // * 说æï¼1128 // *1129 // */1130 // barrage: {1131 // tpl: function () {1132 // return {1133 // retcode: "000000",1134 // retmsg: "ok",1135 // msg: [1136 // {1137 // _method_: 'barrage-refresh',1138 // action: "0",1139 // touid: 0,1140 // msgtype: "1",1141 // uname: 'sys-super',1142 // uid: '-10000',1143 // liangname: "0",1144 // vip_type: "0",1145 // ct: '',1146 // guard_type: "10",1147 // usertype: "60",1148 // },1149 // ],1150 // };1151 // },1152 // //å·æ°1153 // refresh: function () {1154 // console.log(room.action.barrage.tpl());1155 // socket.emit("broadcast", room.action.barrage.tpl());1156 // }1157 // },1158 // /**1159 // *1160 // * è¶
管踢åº1161 // *1162 // * @return mixed $data default string,1163 // * @example1164 // * 说æï¼1165 // *1166 // */1167 // kick: {1168 // //模æ¿1169 // tpl: function (paermission, uid, nick_name) {1170 // return {1171 // retcode: "000000",1172 // retmsg: "ok",1173 // msg: [1174 // {1175 // _method_: "KickUser",1176 // action: "2",1177 // touid: uid,1178 // touname: nick_name,1179 // msgtype: "4",1180 // uname: nick_name,1181 // uid: uid,1182 // liangname: "0",1183 // vip_type: "0",1184 // ct: nick_name + "被踢åºæ¿é´",1185 // guard_type: "10",1186 // usertype: "30",1187 // },1188 // ],1189 // };1190 // },1191 // click: function (nick_name, paermission, uid, room_id) {1192 // room.alert(nick_name, paermission, uid, room_id, config.kick, room.action.kick.send);1193 // },1194 // emit: function (nick_name, paermission, uid, room_id) {1195 // room.ajax(config.method, '/admin/onlines-kick/' + uid + '/' + room_id, function (data) {1196 // if (data.code == 200) {1197 // //å é¤1198 // room.showHide(data.data.paermission, uid, room_id, 'kick');1199 // if (data.data.paermission == 'disabled') {1200 // //广æéç¥1201 // socket.emit("broadcast", room.action.kick.tpl(data.data.paermission, uid, nick_name));1202 // }1203 // //æ示æä½æå1204 // room.alertSuccess();1205 // } else {1206 // //æ示æä½å¤±è´¥1207 // room.alertError(data.message);1208 // }1209 // });1210 // },12111212 },12131214 // /**1215 // *1216 // * è¶
管ç¦è¨1217 // *1218 // * @return mixed $data default string,1219 // * @example1220 // * 说æï¼1221 // *1222 // */1223 // shut: {1224 // //模æ¿1225 // tpl: function (paermission, uid, nick_name) {1226 // let method =1227 // paermission == "disabled" ? "ShutUpUser" : "ResumeUser";1228 // return {1229 // retcode: "000000",1230 // retmsg: "ok",1231 // msg: [1232 // {1233 // _method_: method,1234 // action: "0",1235 // touid: uid,1236 // msgtype: "1",1237 // uname: nick_name,1238 // uid: uid,1239 // liangname: "0",1240 // vip_type: "0",1241 // ct: nick_name + (method == "ShutUpUser" ? "被ç¦è¨äº" : "ç¦è¨è§£é¤äº"),1242 // guard_type: "10",1243 // usertype: "30",1244 // },1245 // ],1246 // };1247 // },1248 // click: function (nick_name, paermission, uid, room_id) {1249 // room.alert(nick_name, paermission, uid, room_id, config.shut, room.action.shut.send);1250 // },1251 // emit: function (nick_name, paermission, uid, room_id) {1252 // room.ajax(config.method, '/admin/onlines-shut/' + uid + '/' + room_id, function (data) {1253 // if (data.code == 200) {1254 // //éèææ¾ç¤ºå¾æ 1255 // room.showHide(data.data.paermission, uid, room_id, 'shut');1256 // //广æéç¥1257 // socket.emit("broadcast", room.action.shut.tpl(data.data.paermission, uid, nick_name));1258 // //æ示æä½æå1259 // room.alertSuccess();1260 // } else {1261 // //æ示æä½å¤±è´¥1262 // room.alertError(data.message);1263 // }1264 // });1265 // },1266 // }12671268 // },1269 // alertSuccess: function () {1270 // swal({1271 // title: 'æä½æå',1272 // icon: 'success',1273 // });1274 // },1275 // alertError: function (message) {1276 // swal({1277 // title: message,1278 // icon: 'warning',1279 // });1280 // },1281 // alert: function (nick_name, paermission, uid, room_id, text, callback) {1282 // swal({1283 // title: paermission == "allow" ? "æ¯å¦ç¡®è®¤" + text : "æ¯å¦ç¡®è®¤è§£é¤" + text,1284 // text: "",1285 // type: "warning",1286 // showCancelButton: true,1287 // confirmButtonText: "确认",1288 // cancelButtonText: "åæ¶",1289 // }).then(function (res) {1290 // if (res.value) {1291 // return callback(nick_name, paermission, uid, room_id);1292 // }1293 // });1294 // },1295 // showHide: function (paermission, uid, room_id, id) {1296 // if (paermission == 'allow') {1297 // $('#' + id + '_' + uid + '_' + room_id + '_allow').show();1298 // $('#' + id + '_' + uid + '_' + room_id + '_disabled').hide();1299 // } else {1300 // $('#' + id + '_' + uid + '_' + room_id + '_allow').hide();1301 // $('#' + id + '_' + uid + '_' + room_id + '_disabled').show();1302 // }1303 // },1304 // ajax: function (method, url, callback) {1305 // $.ajax({method: method, url: url, success: callback});1306 // }13071308}13091310export default {1311 // live,1312 room...
VehicleDataTypeTests.js
Source:VehicleDataTypeTests.js
...3const Validator = require('./../../../Validator.js');4describe('VehicleDataTypeTests', function () {5 it('testValidEnums', function (done) {6 let example = 'VEHICLEDATA_GPS';7 const enumVehicledataGps = VehicleDataType.valueForKey(example);8 example = 'VEHICLEDATA_SPEED';9 const enumVehicledataSpeed = VehicleDataType.valueForKey(example);10 example = 'VEHICLEDATA_RPM';11 const enumVehicledataRpm = VehicleDataType.valueForKey(example);12 example = 'VEHICLEDATA_FUELLEVEL';13 const enumVehicledataFuellevel = VehicleDataType.valueForKey(example);14 example = 'VEHICLEDATA_FUELLEVEL_STATE';15 const enumVehicledataFuellevelState = VehicleDataType.valueForKey(example);16 example = 'VEHICLEDATA_FUELCONSUMPTION';17 const enumVehicledataFuelconsumption = VehicleDataType.valueForKey(example);18 example = 'VEHICLEDATA_CLIMATEDATA';19 const enumVehicledataClimatedata = VehicleDataType.valueForKey(example);20 example = 'VEHICLEDATA_EXTERNTEMP';21 const enumVehicledataExterntemp = VehicleDataType.valueForKey(example);22 example = 'VEHICLEDATA_VIN';23 const enumVehicledataVin = VehicleDataType.valueForKey(example);24 example = 'VEHICLEDATA_PRNDL';25 const enumVehicledataPrndl = VehicleDataType.valueForKey(example);26 example = 'VEHICLEDATA_TIREPRESSURE';27 const enumVehicledataTirepressure = VehicleDataType.valueForKey(example);28 example = 'VEHICLEDATA_ODOMETER';29 const enumVehicledataOdometer = VehicleDataType.valueForKey(example);30 example = 'VEHICLEDATA_BELTSTATUS';31 const enumVehicledataBeltstatus = VehicleDataType.valueForKey(example);32 example = 'VEHICLEDATA_BODYINFO';33 const enumVehicledataBodyinfo = VehicleDataType.valueForKey(example);34 example = 'VEHICLEDATA_DEVICESTATUS';35 const enumVehicledataDevicestatus = VehicleDataType.valueForKey(example);36 example = 'VEHICLEDATA_ECALLINFO';37 const enumVehicledataEcallinfo = VehicleDataType.valueForKey(example);38 example = 'VEHICLEDATA_AIRBAGSTATUS';39 const enumVehicledataAirbagstatus = VehicleDataType.valueForKey(example);40 example = 'VEHICLEDATA_EMERGENCYEVENT';41 const enumVehicledataEmergencyevent = VehicleDataType.valueForKey(example);42 example = 'VEHICLEDATA_CLUSTERMODESTATUS';43 const enumVehicledataClustermodestatus = VehicleDataType.valueForKey(example);44 example = 'VEHICLEDATA_MYKEY';45 const enumVehicledataMykey = VehicleDataType.valueForKey(example);46 example = 'VEHICLEDATA_BRAKING';47 const enumVehicledataBraking = VehicleDataType.valueForKey(example);48 example = 'VEHICLEDATA_WIPERSTATUS';49 const enumVehicledataWiperstatus = VehicleDataType.valueForKey(example);50 example = 'VEHICLEDATA_HEADLAMPSTATUS';51 const enumVehicledataHeadlampstatus = VehicleDataType.valueForKey(example);52 example = 'VEHICLEDATA_BATTVOLTAGE';53 const enumVehicledataBattvoltage = VehicleDataType.valueForKey(example);54 example = 'VEHICLEDATA_ENGINETORQUE';55 const enumVehicledataEnginetorque = VehicleDataType.valueForKey(example);56 example = 'VEHICLEDATA_ACCPEDAL';57 const enumVehicledataAccpedal = VehicleDataType.valueForKey(example);58 example = 'VEHICLEDATA_STEERINGWHEEL';59 const enumVehicledataSteeringwheel = VehicleDataType.valueForKey(example);60 example = 'VEHICLEDATA_TURNSIGNAL';61 const enumVehicledataTurnsignal = VehicleDataType.valueForKey(example);62 example = 'VEHICLEDATA_FUELRANGE';63 const enumVehicledataFuelrange = VehicleDataType.valueForKey(example);64 example = 'VEHICLEDATA_ENGINEOILLIFE';65 const enumVehicledataEngineoillife = VehicleDataType.valueForKey(example);66 example = 'VEHICLEDATA_ELECTRONICPARKBRAKESTATUS';67 const enumVehicledataElectronicparkbrakestatus = VehicleDataType.valueForKey(example);68 example = 'VEHICLEDATA_CLOUDAPPVEHICLEID';69 const enumVehicledataCloudappvehicleid = VehicleDataType.valueForKey(example);70 example = 'VEHICLEDATA_OEM_CUSTOM_DATA';71 const enumVehicledataOemCustomData = VehicleDataType.valueForKey(example);72 example = 'VEHICLEDATA_STABILITYCONTROLSSTATUS';73 const enumVehicledataStabilitycontrolsstatus = VehicleDataType.valueForKey(example);74 example = 'VEHICLEDATA_HANDSOFFSTEERING';75 const enumVehicledataHandsoffsteering = VehicleDataType.valueForKey(example);76 example = 'VEHICLEDATA_WINDOWSTATUS';77 const enumVehicledataWindowstatus = VehicleDataType.valueForKey(example);78 example = 'VEHICLEDATA_GEARSTATUS';79 const enumVehicledataGearstatus = VehicleDataType.valueForKey(example);80 example = 'VEHICLEDATA_SEATOCCUPANCY';81 const enumVehicledataSeatoccupancy = VehicleDataType.valueForKey(example);82 Validator.assertNotNullUndefined(enumVehicledataGps, 'VEHICLEDATA_GPS returned null.');83 Validator.assertNotNullUndefined(enumVehicledataSpeed, 'VEHICLEDATA_SPEED returned null.');84 Validator.assertNotNullUndefined(enumVehicledataRpm, 'VEHICLEDATA_RPM returned null.');85 Validator.assertNotNullUndefined(enumVehicledataFuellevel, 'VEHICLEDATA_FUELLEVEL returned null.');86 Validator.assertNotNullUndefined(enumVehicledataFuellevelState, 'VEHICLEDATA_FUELLEVEL_STATE returned null.');87 Validator.assertNotNullUndefined(enumVehicledataFuelconsumption, 'VEHICLEDATA_FUELCONSUMPTION returned null.');88 Validator.assertNotNullUndefined(enumVehicledataClimatedata, 'VEHICLEDATA_CLIMATEDATA returned null.');89 Validator.assertNotNullUndefined(enumVehicledataExterntemp, 'VEHICLEDATA_EXTERNTEMP returned null.');90 Validator.assertNotNullUndefined(enumVehicledataVin, 'VEHICLEDATA_VIN returned null.');91 Validator.assertNotNullUndefined(enumVehicledataPrndl, 'VEHICLEDATA_PRNDL returned null.');92 Validator.assertNotNullUndefined(enumVehicledataTirepressure, 'VEHICLEDATA_TIREPRESSURE returned null.');93 Validator.assertNotNullUndefined(enumVehicledataOdometer, 'VEHICLEDATA_ODOMETER returned null.');94 Validator.assertNotNullUndefined(enumVehicledataBeltstatus, 'VEHICLEDATA_BELTSTATUS returned null.');95 Validator.assertNotNullUndefined(enumVehicledataBodyinfo, 'VEHICLEDATA_BODYINFO returned null.');96 Validator.assertNotNullUndefined(enumVehicledataDevicestatus, 'VEHICLEDATA_DEVICESTATUS returned null.');97 Validator.assertNotNullUndefined(enumVehicledataEcallinfo, 'VEHICLEDATA_ECALLINFO returned null.');98 Validator.assertNotNullUndefined(enumVehicledataAirbagstatus, 'VEHICLEDATA_AIRBAGSTATUS returned null.');99 Validator.assertNotNullUndefined(enumVehicledataEmergencyevent, 'VEHICLEDATA_EMERGENCYEVENT returned null.');100 Validator.assertNotNullUndefined(enumVehicledataClustermodestatus, 'VEHICLEDATA_CLUSTERMODESTATUS returned null.');101 Validator.assertNotNullUndefined(enumVehicledataMykey, 'VEHICLEDATA_MYKEY returned null.');102 Validator.assertNotNullUndefined(enumVehicledataBraking, 'VEHICLEDATA_BRAKING returned null.');103 Validator.assertNotNullUndefined(enumVehicledataWiperstatus, 'VEHICLEDATA_WIPERSTATUS returned null.');104 Validator.assertNotNullUndefined(enumVehicledataHeadlampstatus, 'VEHICLEDATA_HEADLAMPSTATUS returned null.');105 Validator.assertNotNullUndefined(enumVehicledataBattvoltage, 'VEHICLEDATA_BATTVOLTAGE returned null.');106 Validator.assertNotNullUndefined(enumVehicledataEnginetorque, 'VEHICLEDATA_ENGINETORQUE returned null.');107 Validator.assertNotNullUndefined(enumVehicledataAccpedal, 'VEHICLEDATA_ACCPEDAL returned null.');108 Validator.assertNotNullUndefined(enumVehicledataSteeringwheel, 'VEHICLEDATA_STEERINGWHEEL returned null.');109 Validator.assertNotNullUndefined(enumVehicledataTurnsignal, 'VEHICLEDATA_TURNSIGNAL returned null.');110 Validator.assertNotNullUndefined(enumVehicledataFuelrange, 'VEHICLEDATA_FUELRANGE returned null.');111 Validator.assertNotNullUndefined(enumVehicledataEngineoillife, 'VEHICLEDATA_ENGINEOILLIFE returned null.');112 Validator.assertNotNullUndefined(enumVehicledataElectronicparkbrakestatus, 'VEHICLEDATA_ELECTRONICPARKBRAKESTATUS returned null.');113 Validator.assertNotNullUndefined(enumVehicledataCloudappvehicleid, 'VEHICLEDATA_CLOUDAPPVEHICLEID returned null.');114 Validator.assertNotNullUndefined(enumVehicledataOemCustomData, 'VEHICLEDATA_OEM_CUSTOM_DATA returned null.');115 Validator.assertNotNullUndefined(enumVehicledataStabilitycontrolsstatus, 'VEHICLEDATA_STABILITYCONTROLSSTATUS returned null.');116 Validator.assertNotNullUndefined(enumVehicledataHandsoffsteering, 'VEHICLEDATA_HANDSOFFSTEERING returned null.');117 Validator.assertNotNullUndefined(enumVehicledataWindowstatus, 'VEHICLEDATA_WINDOWSTATUS returned null.');118 Validator.assertNotNullUndefined(enumVehicledataGearstatus, 'VEHICLEDATA_GEARSTATUS returned null.');119 Validator.assertNotNullUndefined(enumVehicledataSeatoccupancy, 'VEHICLEDATA_SEATOCCUPANCY returned null.');120 done();121 });122 it('testInvalidEnum', function (done) {123 const example = 'nIGHT';124 const temp = VehicleDataType.valueForKey(example);125 Validator.assertNull(temp, 'Result of valueForKey should be null.');126 done();127 });128 it('testNullEnum', function (done) {129 const example = null;130 const temp = VehicleDataType.valueForKey(example);131 Validator.assertNull(temp, 'Result of valueForKey should be null.');132 done();133 });...
Using AI Code Generation
1var obj = {2 "cars": {3 }4};5console.log(obj.cars.car1);6var obj = {7 "cars": {8 }9};10console.log(obj.cars.car1);11var obj = {12 "cars": {13 }14};15console.log(obj.cars.car1);16var obj = {17 "cars": {18 }19};20console.log(obj.cars.car1);21var obj = {22 "cars": {23 }24};25console.log(obj.cars.car1);26var obj = {27 "cars": {28 }29};30console.log(obj.cars.car1);31var obj = {32 "cars": {33 }34};35console.log(obj.cars.car1);36var obj = {
Using AI Code Generation
1const unexpected = require('unexpected');2const unexpectedReact = require('unexpected-react');3const unexpectedSinon = require('unexpected-sinon');4const expect = unexpected.clone().use(unexpectedReact).use(unexpectedSinon);5const React = require('react');6const TestComponent = React.createClass({7 render() {8 return (9 );10 },11});12describe('TestComponent', () => {13 it('renders a h1 tag', () => {14 const component = <TestComponent />;15 expect(component, 'to have rendered', <h1>Hello World</h1>);16 });17});18{19 "scripts": {20 },21 "devDependencies": {22 },23 "dependencies": {24 }25}260 passing (9ms)
Using AI Code Generation
1var unexpected = require('unexpected');2var expect = unexpected.clone();3var obj = {4 "cars": {5 }6};7expect(obj, 'to have key', 'name');8expect(obj, 'to have key', 'age');9expect(obj, 'to have key', 'cars');10expect(obj, 'to have key', 'car1');11expect(obj, 'to have key', 'car2');12expect(obj, 'to have key', 'car3');13expect(obj, 'to have key', 'name');14expect(obj, 'to have key', 'age');15expect(obj, 'to have key', 'cars');16expect(obj, 'to have key', 'car1');17expect(obj, 'to have key', 'car2');18expect(obj, 'to have key', 'car3');19var unexpected = require('unexpected');20var expect = unexpected.clone();21var obj = {22 "cars": {23 }24};25expect(obj, 'to have key path', 'cars.car1');26expect(obj, 'to have key path', 'cars.car2');27expect(obj, 'to have key path', 'cars.car3');28expect(obj, 'to have key path', 'cars.car1');29expect(obj, 'to have key path', 'cars.car2');30expect(obj, 'to have key path', 'cars.car3');31var unexpected = require('unexpected');32var expect = unexpected.clone();33var obj = {34 "cars": {35 }36};37expect(obj, 'to have key', 'name');38expect(obj, 'to have key', 'age');39expect(obj, 'to have key', 'cars');40expect(obj, 'to have key', 'car1');41expect(obj, 'to have key', 'car2');42expect(obj
Using AI Code Generation
1var unexpected = require('unexpected');2var expect = unexpected.clone();3var a = 2;4var b = 3;5expect(a, 'to equal', b);6 at AssertionError (native)7 at Context.<anonymous> (/Users/username/test.js:7:13)8 at callFn (/Users/username/node_modules/mocha/lib/runnable.js:334:21)9 at Test.Runnable.run (/Users/username/node_modules/mocha/lib/runnable.js:327:7)10 at Runner.runTest (/Users/username/node_modules/mocha/lib/runner.js:429:10)11 at next (/Users/username/node_modules/mocha/lib/runner.js:341:14)12 at next (/Users/username/node_modules/mocha/lib/runner.js:285:14)13 at Immediate._onImmediate (/Users/username/node_modules/mocha/lib/runner.js:319:5)14 at processImmediate [as _immediateCallback] (timers.js:383:17)15at AssertionError (native)16at Context.<anonymous> (/Users/username/test.js:7:13)17at callFn (/Users/username/node_modules/mocha/lib/runnable.js:334:21)18at Test.Runnable.run (/Users/username/node_modules/mocha/lib/runnable.js:327:7)19at Runner.runTest (/Users/username/node_modules/mocha/lib/runner.js:429:10)20at next (/Users/username/node_modules/mocha/lib/runner.js:341:14)21at next (/Users/username/node_modules/mocha/lib/runner.js:285:14)22at Immediate._onImmediate (/Users/username/node_modules/mocha/lib/runner.js
Using AI Code Generation
1var unexpected = require('unexpected');2var expect = unexpected.clone();3var obj = {a:1,b:2};4var value = expect(obj, 'to have key', 'a');5console.log(value);6var unexpected = require('unexpected');7var expect = unexpected.clone();8var obj = {a:1,b:2};9var value = expect(obj, 'to have key', 'a');10console.log(value);11var unexpected = require('unexpected');12var expect = unexpected.clone();13var obj = {a:1,b:2};14var value = expect(obj, 'to have key', 'b');15console.log(value);16var unexpected = require('unexpected');17var expect = unexpected.clone();18var obj = {a:1,b:2};19var value = expect(obj, 'to have key', 'c');20console.log(value);21var unexpected = require('unexpected');22var expect = unexpected.clone();23var obj = {a:1,b:2};24var value = expect(obj, 'to have key', 'c');25console.log(value);26var unexpected = require('unexpected');27var expect = unexpected.clone();28var obj = {a:1,b:2};29var value = expect(obj, 'to have key', 'a');30console.log(value);31var unexpected = require('unexpected');32var expect = unexpected.clone();33var obj = {a:1,b:2};34var value = expect(obj, 'to have key', 'b');35console.log(value);
Using AI Code Generation
1var unexpectedObject = require('./unexpectedObject');2var result = unexpectedObject.valueForKey('name');3console.log(result);4var unexpectedObject = {5 valueForKey: function (key) {6 return this[key];7 }8};9module.exports = unexpectedObject;
Using AI Code Generation
1console.log("Running test.js");2var test = require('./test2.js');3console.log(test);4var test2 = test.valueForKey("a");5console.log(test2);6console.log("Running test2.js");7var test = {8};9module.exports = test;10{ a: 'test' }11console.log("Running test2.js");12var test = function() {13 return {14 };15};16module.exports = test();17{ a: 'test' }18console.log("Running test2.js");19var test = function() {20 return {21 b: function() {22 return "test2";23 }24 };25};26module.exports = test();27console.log("Running test.js");28var test = require('./test2.js');29console.log(test);30var test2 = test.b();31console.log(test2);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!