Files
Testing/mongolian/demos/api/send_message.html
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

68 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Magnoliyan Video Chat</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<link rel="stylesheet" href="../../mgVideoChat/mgVideoChat-1.18.0.css">
</head>
<body>
<div class="container">
<h1>MgVChat <small>Events API</small></h1>
<div class="alert alert-info" role="alert">
If no one else is in the room, please open the same page in other tab to do self-test.
</div>
<button id="customSendMessage" class="btn-success">send message</button>
</div>
<div id="mgVideoChat"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
<!-- Video Chat -->
<script src="../../mgVideoChat/mgVideoChat-1.18.0-min.js"></script>
<script src="../common/js/menu.js"></script>
<script>
//global instaces of chat objects
var rtc, mgChat;
$(document).ready(function(){
//init plugin
mgChat = $('#mgVideoChat').mgVideoChat({
wsURL: wsUrlDefault + '?room=1'
});
//attach to plugin events
//on call status change
$('#mgVideoChat').mgVideoChat('on','call_status',function(connectionId, status){
console.log('[mgVideoChat.call_status] fired',connectionId, status);
});
//on chat message
$('#mgVideoChat').mgVideoChat('on','chat_message',function(data){
console.log('[mgVideoChat.chat_message] fired', data);
});
//on logged in
$('#mgVideoChat').mgVideoChat('on','logged',function(){
console.log('[mgVideoChat.logged] fired');
});
//get low level rtc object
rtc = mgChat.getRtc();
//attach to rtc object low level events
rtc.on('chat_message', function(data) {
console.log('[mgRtc.chat_message] fired', data);
});
$("#customSendMessage").click(function(){
//log peer connections
console.log(rtc.connections);
var message = prompt("Enter message text", "Message");
var connectionId = prompt("Enter destination connection id");
if(message && connectionId){
//use rtc object to send a message to a connection
rtc.chatMessage(connectionId, message);
}
});
});
</script>
</body>
</html>