Skip to content

Commit c7ffd0a

Browse files
committed
Send message
1 parent 0950acd commit c7ffd0a

8 files changed

+61
-20
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@angular/platform-browser": "~7.0.0",
2121
"@angular/platform-browser-dynamic": "~7.0.0",
2222
"@angular/router": "~7.0.0",
23-
"@stomp/ng2-stompjs": "^7.0.0-beta.2",
23+
"@stomp/ng2-stompjs": "^7.0.0-beta.3",
2424
"core-js": "^2.5.4",
2525
"rxjs": "~6.3.3",
2626
"zone.js": "~0.8.26"

src/app/app.component.html

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
<!--The content below is only a placeholder and can be replaced.-->
21
<div style="text-align:center">
32
<h1>
43
Welcome to {{ title }}!
54
</h1>
6-
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
75
</div>
8-
<h2>Here are some links to help you start: </h2>
9-
<ul>
10-
<li>
11-
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12-
</li>
13-
<li>
14-
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15-
</li>
16-
<li>
17-
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
18-
</li>
19-
</ul>
20-
6+
<app-messages></app-messages>

src/app/app.module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { InjectableRxStompConfig, RxStompService, rxStompServiceFactory } from '
55

66
import { AppComponent } from './app.component';
77
import { myRxStompConfig } from './my-rx-stomp.config';
8+
import { MessagesComponent } from './messages/messages.component';
89

910
@NgModule({
1011
declarations: [
11-
AppComponent
12+
AppComponent,
13+
MessagesComponent
1214
],
1315
imports: [
1416
BrowserModule

src/app/messages/messages.component.css

Whitespace-only changes.
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div id="messages">
2+
<button class="btn btn-primary" (click)="onSendMessage()">Send Message</button>
3+
<h2>Received messages</h2>
4+
<ol>
5+
<!-- we will use Angular binding to populate list of messages -->
6+
<li class="message">message</li>
7+
</ol>
8+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { MessagesComponent } from './messages.component';
4+
5+
describe('MessagesComponent', () => {
6+
let component: MessagesComponent;
7+
let fixture: ComponentFixture<MessagesComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ MessagesComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(MessagesComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { RxStompService} from '@stomp/ng2-stompjs';
3+
4+
@Component({
5+
selector: 'app-messages',
6+
templateUrl: './messages.component.html',
7+
styleUrls: ['./messages.component.css']
8+
})
9+
export class MessagesComponent implements OnInit {
10+
11+
constructor(private rxStompService: RxStompService) { }
12+
13+
ngOnInit() {
14+
}
15+
16+
onSendMessage() {
17+
const message = `Message generated at ${new Date}`;
18+
this.rxStompService.publish({destination: '/topic/demo', body: message});
19+
}
20+
}

0 commit comments

Comments
 (0)