Discipline yourself to sit down and "attend" class. Put a timer on and work the learning in 40 minute increments. - Complete your assignments as you would for any face-to-face course. Maybe better!
Schedule exactly when you are going to "attend" class and stick to it!
Set aside enough time to complete assignments as scheduled. Remember, online you set aside time to "learn" and a time to complete assignments.
If at all possible, make a place in a corner of your living room, kitchen, bedroom that is just for your online studies. Don't try to learn and study in the same spot you play. That means, where you study and learn is NOT where you stream your best shows and movies or play online games.
If your course includes discussions, either assigned or open forum, use these to engage with your fellow course mates. Especially open forums ARE a good place to communicate, even when you're not in your learning space.